public class Main {
public static void main(String[] args) {
byte a=10;
byte b=20;
Integer c=a+b;
System.out.println(c);
}
这个是否可以输出呢???我们可以想一想
答案是可以的,为什么呢?
因为在开始的时候会将a+b转换成a.byteValue()+b.byteValue()然后再进行运算,在编译的时候因为存在+号,在编译的时候+号会被编译成iadd,这里就会被编译成int类型,所以byte类型相加会得到int类型