日期:2014-05-20 浏览次数:20709 次
public class Cases{
public static void main (String[] arguments){
float x=9;
float y=5;
int z=(int)(x/y);
switch(z){
case 1:
x=x+2;
case 2:
x=x+3;
default:
x=x+1;
}
System.out.println("Value of "+x);
}
}
public class Cases{
public static void main (String[] arguments){
float x=9;
float y=5;
int z=(int)(x/y); //z=1,x=9
switch(z){
case 1:
x=x+2; //x=9+2=11,没有break , 继续向下执行.
case 2:
x=x+3; //x=11+3=14
default:
x=x+1; //x=14+1=15
}
System.out.println("Value of "+x);
}
}