package dahu.demo;
/*
容量小的往容量大的方向升,byte(-128~127),short.int,long.float,double;
容量指数值大小
*/
public class test3 {
public static void main(String []args) {
short b1 = 12;
int b2 = 4;
int i1 = b1 + b2;
System.out.println(i1);
}
}
2.强制类型转换
1.需要使用强制符
2.强转,可能导致精度损失
package dahu.demo;
public class test4 {
public static void main(String []args){
double b1=13.2;
int i1=(int)b1;
System.out.println(i1);
//精度损失
int i2=128;
byte b2=(byte)i2;
System.out.println(b2);
}
}