Reputation: 13
Recently stumped upon this line in a program, and I have no idea what the bracket for (List<Level>
) is for . Anybody got any idea ?
List<Level> levelList = (List<Level>)dao.getAllLevels();
Upvotes: 0
Views: 93
Reputation: 13539
Its called typecasting. The data returned from dao.getAllLevels() is being casted into type List
.
This operation might not always be successful, and in that case jvm/jre
throws a ClassCastException
. You can read more about object typecasting in Java here.
More about java and type-casting on Stackoverflow:
Upvotes: 2
Reputation: 2398
It's called a cast. It's used to enforce the type of the following variable, in this case, to be sure that dao.getAllLevels() returns an object of type List.
Upvotes: 0