第六题
int x = 2,y=3;
switch(x)
{
default:
y++;
case 3:
y++;
case 4:
y++;
}
System.out.println("y="+y);//y=6
class Demo
{
public static void main(String[] args)
{
show(0);//15
show(1);//14
}
public static void show(int i)
{
switch(i)
{
default:
i+=2;
case 1:
i+=1;
case 4:
i+=8;
case 2:
i+=4;
}
System.out.println("i="+i);
}
} |
|