具有缩小概念的三元运算符
Ternary operator with narrowing concept
为什么以下语句在编译时显示错误
int a=10,b=20;
byte c=(a<b)?40:50;
System.out.println(c);
b 已经声明。
你可以试试
int a=10,b=20;
byte c=(byte) ((a<b)?40:50);
System.out.println(c);
为什么以下语句在编译时显示错误
int a=10,b=20;
byte c=(a<b)?40:50;
System.out.println(c);
b 已经声明。
你可以试试
int a=10,b=20;
byte c=(byte) ((a<b)?40:50);
System.out.println(c);