隐式转换
- (byte,short,char)->int->long->float->double
public class test {
public static void main(String[] args) {
byte a = 10;
int b=a;
long c=a;
float d=a;
double e=a;
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println(d);
System.out.println(e);
char f='c';
int g=f; //char类型会转换为ascii码值
System.out.println(g);
}
}
- byte,short,char是评级的,不能自动转换
强制类型转换
参考:
https://www.jianshu.com/p/e7fd5f28305d