JSのスイッチの中のdefaultの使い方
8677 ワード
default ?default ?
default case
int a=4;
switch (a){
case 1:
System.out.println("1");
break;
case 2:
System.out.println("2");
break;
case 3:
System.out.println("3");
break;
default:
System.out.println("default");
break;
}
:default
, case , break
int a=3;
switch (a){
case 1:
System.out.println("1");
break;
case 2:
System.out.println("2");
break;
case 3:
System.out.println("3");
default:
System.out.println("default");
break;
}
:
3
default
default , default break, break
int a=4;
switch (a){
default:
System.out.println("default");
break;
case 1:
System.out.println("1");
break;
case 2:
System.out.println("2");
break;
case 3:
System.out.println("3");
break;
}
:default
break
int a=4;
switch (a){
default:
System.out.println("default");
case 1:
System.out.println("1");
case 2:
System.out.println("2");
break;
case 3:
System.out.println("3");
break;
}
:
default
1
2
break , break return switch