public class client(
public static void main(String [] argw){
System.out.println("2 = "+numCase(2));
}
public static String numCase(int n){
String ChinessNumber="";
swith(n){
case 0:ChinessNumber="零";
case 0:ChinessNumber="壹";
case 0:ChinessNumber="貳";
case 0:ChinessNumber="三";
case 0:ChinessNumber="肆";
case 0:ChinessNumber="伍";
case 0:ChinessNumber="陸";
case 0:ChinessNumber="柒";
case 0:ChinessNumber="捌";
case 0:ChinessNumber="玖";
}
return ChinessNumber;
}
)
結果 是 2=玖
case語句後邊一定要加上break;
可以這樣解決:修改IDE的警告級別,例如在Eclipse中,可以以Performaces-java-compiler-Errors/Warnings-Potential Programming problems,然後修改‘swith’ case fall-through 這Errors級別,如果你膽敢不在case語句中加入break,那麼Eclipse直接就報個紅叉給你看看