package type; public class TypeCvDemo2 { public static void main(String[] args) { //目标表达 式类型自动转换 小范围向大范围转换 byte a = 10; int b = 20; long c = 30 ; long r = a + b + c; System.out.println(r); double rs2 = a + b + c +r ; System.out.println(rs2); //注意在表达式中 byte short char直接转换成int类型 byte i = 10 ; short j = 30 ; // short ad = i + j ; 你打这个会发现报错 因为我们默认int类型,但是short比Int小范围 int asd = i +j ; System.out.println(asd); //常考类型题 byte b1 = 10; byte b2 = 88; //byte b3 = b1 + b2;错误 int b3 = b1 + b2; System.out.println(b3); } }标签:类型转换,short,int,System,println,3.29,byte,out,范围 From: https://blog.csdn.net/worm_kinging/article/details/137166463