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();
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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/jrethrows aClassCastException. You can read more about object typecasting in Java here.More about java and type-casting on Stackoverflow: