...
| Code Block | ||
|---|---|---|
| ||
int card = 11;
switch (card) {
/* ... */
case 11:
System.out.println("Jack""Jack");
case 12:
System.out.println("Queen""Queen");
break;
case 13:
System.out.println("King""King");
break;
default:
System.out.println(""Invalid Card"");
break;
}
|
Compliant Solution
...
| Code Block | ||
|---|---|---|
| ||
int card = 11;
switch (card) {
/* ... */
case 11:
System.out.println("Jack""Jack");
break;
case 12:
System.out.println("Queen""Queen");
break;
case 13:
System.out.println("King""King");
break;
default:
System.out.println(""Invalid Card"");
break;
}
|
Exceptions
EX1: The last label in a switch statement requires no break. The break statement serves to skip to the end of the switch block, so control transfers to statements following the switch block irrespective of its presence. Conventionally, the last label is the default label.
...
| Wiki Markup |
|---|
\[[JLS 05|AA. Java References#JLS 05]\] [Section 14.11 The switch Statement|http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.11] |
...
IDS15-J. Library methods should validate their parameters MSC05-J. Do not mix generic with non-generic raw types in new code 49. Miscellaneous (MSC) MSC07-J. Do not assume infinite heap space