Java学习笔记_180625

1.基本数据类型

byte,short,int,long,char,float,double,boolean

 type lenth(Byte)  初始值 
 byte  0
short   0
int   0
long   0L
char   ‘\u0000’
float   0.0f
double   0.0
boolen   4或1  false

boolean的长度没有明确定论,组成数组时boolean占1Byte,单独定义时占4个Byte

2.类型转换

2.1自动转换

-容量小的类型可以自动转换为容量大的类型

-byte,short,char之间不会自动转换,需要先转化成int类型

-基本类型和字符串进行“+”运算时会将基本类型转换为字符串类型

2.2强制转换

-强制转换可以将容量大的类型转换为容量小的类型,但可能产生精度降低或溢出

猜你喜欢

转载自www.cnblogs.com/annofyf/p/9223719.html