注意:Java中Switch语句的参数类型-_-!...
Java中不能将float和doublu类数据作为switch(...)中的表达式!
其它语言有待验证-_-!...
其它语言有待验证-_-!...
验证代码如下:
public class test{
public static void main(String[] args) {
float b =1.0f;
//double c=2.0;
switch(b){
case 1.0f:
break;
//case 2.0;
default:
;
}
}
}
出错提示如下:
探索代码的奥秘,享受技术的乐趣-_-!...