I have written small code in java 6
public class TestSwitch{ public static void main(String... args){ int a = 1; System.out.println("start"); switch(a){ case 1:{ System.out.println(1); case 3: System.out.println(3); case 4: System.out.println(4); } case 2:{ System.out.println(2); case 5: System.out.println(5); case 7: System.out.println(7); } } System.out.println("end"); } } Output: start 1 2 end
My editor is showing orphaned case for 'case 3' and 'case 5'.Still it is running and showing output.
Does Nastated cases like concept is there in Java?
And Why it is giving above output? rather i thought it will be 'start 1 end'
Your response will be greatly appreciated!!