以下代码,用eclipes编译后反编译,发现会自动补齐,没有出现的case数字:
public int method(int arg){
int ret = 0;
switch(arg){
case 1:
ret = 1;
break;
case 3:
ret = 3;
break;
case 7:
ret = 1;
break;
case 9:
ret = 1;
break;
case 11:
ret = 1;
break;
default:
ret = 12
break;
}
return ret;
}
编译后:
public int method(int arg){
int ret = 0;
switch(arg){
case 1:
ret = 1;
break;
case 3:
ret = 3;
break;
case 7:
ret = 7;
break;
case 9:
ret = 9;
break;
case 11:
ret = 11;
break;
case 2:
case 4:
case 5:
case 6:
case 8:
case 10:
default:
ret = 12
break;
}
return ret;
}
有的时候就不会出现这种补齐状况,请问这是什么原因,有什么规律么?
谢谢。
------解决方案--------------------