posted 20 years ago
Hi.
While I agree that the lack of break statement is odd, it doesn't really make the assertion in line 15 incorrect. That assertion doesn't fail in the case you described because z IS less than 10 (which is what's being asserted).
As for the variable not being final: that's not a requirement for use in a switch statement. What you're thinking of is that the values in the CASE statements must be constant values. In this example, those values are 4 and 5, which are constants. If you defined a variable:
int FOO = 5;
...and used it in place of the value 5 in the case statement, it would not compile because FOO is not constant.
Hope that helps.
Co-Author of <a href="http://www.oreilly.com/catalog/jswing2" target="_blank" rel="nofollow">Java Swing</a><br />Co-Creator of <a href="http://www.sun.com/training/catalog/courses/CX-310-055.xml" target="_blank" rel="nofollow">SCJP 5.0</a> and <a href="http://www.sun.com/training/certification/java/associate_beta.xml" target="_blank" rel="nofollow">SCJA</a> exams