我發現了一些「有點」相關的問題,但我不確定我的需求是否完全符合這些問題。所以,我期望做的是用SWITCH/CASE清理以下IF/ELSE IF語句。有沒有辦法在Java開關中使用多個條件運算符,還是嚴格布爾值?Java開關 - 不同條件運算符
int alSize = Integer.parseInt(size);
if (alSize == 7 && (alType == 1 || alType == 3)){
disp = 0.12;
}else if (alSize == 9 && (alType == 1 || alType == 3 || alType == 4 || alType == 5)){
disp = 0.27;
}else if (alSize == 9){
disp = 0.21;
}else if (alSize == 11 && (alType == 1 || alType == 3 || alType == 4 || alType == 5)){
disp = 0.47;
}else if (alSize == 11){
disp = 0.41;
}else if (alSize == 12 && (alType == 1 || alType == 3 || alType == 4 || alType == 5)){
disp = 0.75;
}else if (alSize == 12){
disp = 0.64;
}else if (alSize == 14 &&(alType == 1 || alType == 3 || alType == 4 || alType == 5)){
disp = 1.10;
}else if (alSize == 14){
disp = 0.96;
}else if (alSize == 16 && (alType == 1 || alType == 3 || alType == 4 || alType == 5)){
disp = 1.60;
}else if (alSize == 16){
disp = 1.40;
}else if (alSize == 18 && (alType == 1 || alType == 3 || alType == 4 || alType == 5)){
disp = 2.60;
}else if (alSize == 18){
disp = 2.30;
}else if (alSize == 22 && (alType == 1 || alType == 3 || alType == 4 || alType == 5)){
disp = 4.0;
}else if (alSize == 22){
disp = 3.60;
}else if (alSize == 30 && (alType == 1 || alType == 3 || alType == 4 || alType == 5)){
disp = 9.9;
}else if (alSize == 30){
disp = 9.2;
}
我VOT只是因爲這個陳述是如此......哇。 – 2015-02-06 01:11:32