public class ST_SWITCH {
public static void main(String[] args) {
System.out.println("Start");
//
System.out.println("------------------------");
int i = 3;
switch(i)
{
case 1:
System.out.println("i -> One");
break;
case 2:
System.out.println("i -> Two");
break;
case 3:
System.out.println("i -> Three");
break;
default:
System.out.println("error");
break;
}
//breakなし!!
switch(i)
{
case 5:
System.out.println("i > 4");
case 4:
System.out.println("i > 3");
case 3:
System.out.println("i > 2");
case 2:
System.out.println("i > 1");
case 1:
System.out.println("i > 0");
break;
default:
System.out.println("error");
break;
}
//
System.out.println("------------------------");
System.out.println("End");
}
}
|