What will be printed out when the following code is executed?
switch (5) {//www .ja v a 2s. c o m case 0: System.out.println("zero"); break; case 1: System.out.println("one"); default: System.out.println("default"); case 2: System.out.println("two"); }
b
The default case can be positioned anywhere within the switch.
As all of the cases, except the first one, are missing a break statement, flow falls through each of the last three cases.
While it is not common, constants can be used for switch statements.