Falling is the standard behavior for a switch statement, and therefore, therefore, using continue in a switch statement does not make sense. The continue statement is only used for for / while / do..while loops.
Based on my understanding of your intentions, you probably want to write:
System.out.println("default"); if ( (a == 'a') || (a == 'b') ){ System.out.println(a); }
I also suggest that you put the default condition at the very end.
EDIT: It is not entirely true that continue statements cannot be used inside switch statements. A (perfectly labeled) continue statement is fully valid. For instance:
public class Main { public static void main(String[] args) { loop: for (int i=0; i<10; i++) { switch (i) { case 1: case 3: case 5: case 7: case 9: continue loop; } System.out.println(i); } } }
This will lead to the following output: 0 2 4 6 8
source share