class Switch{
public static void main(String[] args){
int x = 2;
switch(x){
case 1 : System.out.println("1");
case 2 : System.out.println("2");
case 3 : System.out.println("3");
case 4 :System.out.println("4");
}
}
}
Why the output will be 2 ,3,4 even if the case 3 and case 4 are not matched with the value of x ?
I know that using break will be printing only 2. But why we have to use break after case 2 as no other cases after it are matching it?