This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
What will be the result of attempting to compile and run the following program?
Correct answer is that the code will fail to compile. Because the value of the case label iFour is not a constant expression.
I totally don't understand. Isn't iFour is a compile time constant and become 4 through unboxing?
This problem come from "A Programmer's Guide to JavaSCJP Certification", Chapter 6.2, page 215.
Amelia Ma wrote:I totally don't understand. Isn't iFour is a compile time constant and become 4 through unboxing?
As a side note to this topic... compile time constants require that the type be a primative or a string. The Java Language Specification currently doesn't support any other type as a compile time constant.