Email address:
Password:
SCJP/OCPJP 1.6 certification
Practice Exams and Training
SCJP Online Training » Discussions

Compilation error

Can you explain me clearly why compilation fails?

As the explanation says "deck1 is a non-final variable, and therefore cannot be used from an anonymous inner class."


The rule to keep in mind for the exam is that you cannot access non-final local variables from within an anonymous inner class. In Java 8, you wouldn't get this error as long as you don't modify the variable.

ExamLab © 2008 - 2024