All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.
Here are the rules: The type of the Expression must be char, byte, short, or int, or a compile-time error occurs.
All of the following must be true, or a compile-time error will result:
This was changed in Java 7
The switch statement compares the String object in its expression with the expressions associated with each case label as if it were using the String.equals method; consequently, the comparison of String objects in switch statements is case sensitive. The Java compiler generates generally more efficient bytecode from switch statements that use String objects than from chained if-then-else statements.
Just to add , Wrapper Classes for char, byte, short, int (i.e. Character, Bye, Short, and Integer) are also allowed as an argument in the switch statements as they are unboxed to the corresponding primitive types.