赞
踩
java中规定,switch中的参数只能是离散变量或枚举类型。
但是 使用string,char也可以编译通过
long,double,float等编译错误
- public class Test_Switch {
- public static void main(String[] args) {
- String s = "a";
- float a = (float) 0.1;
- double b= 0.1;
- Boolean bool_l = true;
- char chara = 'a';
- switch (chara) {
- case 'a':
- System.out.println('a');
- break;
- default:
- break;
- }
- }
- }
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。