首先 default 用在 switch case 语句里。如果参数不满足任何 case,则为 default 情况,一般用法如下:switch(参数) { case 值1: //语句 case 值2: //语句 ...... default: //语句}
int i=(int)(Math.random()*10);switch(i) {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");}
看书。