Java八大基本数据
一、byte 字节型 1个字节
short 短整型 2个字节
int 整型 4个字节
long 长整型 8个字节
float 单精度浮点型 4个字节
double 双精度浮点型 8个字节
boolean 布尔型 1个字节
char 字符型 2个字节
二、取值范围
byte -128~127
short -32768~32767
int -2147483648~2147483647
long 大约900万万亿
char 0~65535
boolean 只有true或false
三、对应的封装类
byte――Byte
short――Short
int――Integer
long――Long
float――Float
double――Double
char――Character
四、基本数据默认值
byte――0
short――0
int――0
long――0
float――0
double――0
char――0
boolean――false
五、基本数据的字面值
整数默认为:int
浮点数默认为:double
byte,short,char运算时自动转换为int类型
浮点数运算时可能会丢失精度,高精度场所使用BigDecimal运算
浮点数的两个特殊值:Infinaty,无穷大
NAN,not a number(不是一个数)
六、基本数据类型的转换
1.)自动转换:小转大(数据的字节数)
2.)强制转换:大转小(需要转换的数据类型)