switch(expr1)中,expr1是一个整数表达式, 整数表达式可以是int基本类型或integer包装类型,由于byte,short,char都可以隐士转换成int类型,所以,这些类型,以及这些类型的包装类型也是可以的。因此传递给switch和case语句的参数应该是int、short、char或者byte,还有enum。long, string都不能用于switch。
switch(expr1)中,expr1是一个整数表达式, 整数表达式可以是int基本类型或integer包装类型,由于byte,short,char都可以隐士转换成int类型,所以,这些类型,以及这些类型的包装类型也是可以的。因此传递给switch和case语句的参数应该是int、short、char或者byte,还有enum。long, string都不能用于switch。