在java中整数类型byte,short与字符型char之间不可自动转换,但三者之间可以进行运行,在运算时会转换为int类型。
byte num1 = 3;
byte num2 = 5;
short num3 = 4;
byte s1 = num1 + num2;//错误,byte之间运算转换为int类型
short s2 = num1 + num2;//错误,byte与short运算转换为int类型
int s3 = num1 + num2;//正确
//精确度大的转换为精确度小的需要强制转换
byte d1 = (byte)(num1 + num2);//正确