1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
/* Free Flowing Switch Statement Example This example shows how case statements are executed if break is not used to terminate the execution of the statments. */ public class FreeFlowingSwitchExample { public static void main(String[] args) { /* * break statement is used to terminate the flow of * matching case statements. If break statement is * not specified, switch statement becomes free flowing and * all cases following matching case including default * would be executed. */ int i=0; switch(i) { case 0: System.out.println("i is 0"); case 1: System.out.println("i is 1"); case 2: System.out.println("i is 2"); default: System.out.println("Free flowing switch example!"); } } } /* Output would be i is 0 i is 1 i is 2 Free flowing switch example! */ |
hi
nice java examples
can u give a problem codes please
can i create nested switch using single variable a & how it works??????
thank you
can u please give me the problem and codes