整型: long short int byte
字符型:char
浮点型: double float
布尔型 : true false
引用类型: 类 接口 数组
小到大:char,byte,short——>int——>long——>float——>double
char 和数字类型的做运算,会根据ascII码表把char类型转化为对应的int类型数字来运算;
byte和short,char做运算的结果是默认自动转化为int类型的数据;
int i1=10;
short s1=2;
int i2 = i1+s1;-- 12
float f1=12.5F;
float f2=f1+i2; --24.5
long l=12L;
float f3 = l; --12.0
char c1= 'a';
char c2= 'A';
int i3 = c1+1; --97+1=98
int i4= c2+1; --65+1=66
//short、byte、char之间的运算结果都被自动转化为int类型
short ss1=12;
byte bb1= 1;
char cc1='a';
int ii1=ss1+bb1+cc1; --110