Java中switch语句作用在long类型上报错Error:(12, 16) java: 不兼容的类型: 从long转换到int可能会有损失
switch表达式的返回值
必须是下述几种类型之一:int, byte, char, short, String;
错误代码:
long a = 123L;
switch (a) {
case 1:
case n:
...
}
提示错误:
Error:(12, 16) java: 不兼容的类型: 从long转换到int可能会有损失
我们看一下char类型
public class Demo1 {
public static void main(String[] args) {
原创
2020-07-17 13:01:48 ·
2181 阅读 ·
0 评论