I got this from the MArcus Green tutorial
public class MySwitch{
public static void main(
String argv[]){
MySwitch ms= new MySwitch();
ms.amethod();
}
public void amethod(){
int k=10;
switch(k){
default: //Put the default at the bottom, not here
System.out.println("This is the default output");
break;
case 10:
System.out.println("ten");
case 20:
System.out.println("twenty");
break;
}
}
}
Tha ans is it prints out ten and twenty as there is no break after the case10 condition.But I thought that even if it falls through to case 20 as it is not satisfied(as k is 10) it wont print out twenty.Please clarify.If so if we dont give break and the default is specified shouldnt it always printout?