| Author |
an enums question
|
Aakash Goel
Ranch Hand
Joined: May 26, 2008
Posts: 198
|
|
This is from ExamLab - paper3
The output is Only A Only B Only C.
How does A [line 1] match the A inside enum? They are completely different!!!
I thought the default case would match.
This [Only A Only B Only C] is the answer I expect if the cases are defined like :
|
SCJP 5 95%
SCJP FAQ | SCJP Mock Tests | SCJP Tipline | Generics
|
 |
pete stein
Bartender
Joined: Feb 23, 2007
Posts: 1561
|
|
|
Per the JLS (14:11): The case labels must be constant expressions, int A is a variable while the enum A is a constant. Also the case label constants must be assignable to the switch expression.
|
 |
 |
|
|
subject: an enums question
|
|
|