java变量和数据类型

java数据类型划分:

基本类型:8种

整形:包括十进制,八进制,十六进制

byte 1字节(8个位) -128~127

short 2字节(16位)

int    4字节(32位)

long 8字节(64字节)   例如默认100为int型,如果要表达为long,需要加L或l

浮点数

float 4字节 单精度   例如3.14的默认数据类型为double ,如果要表达float 后面加f或F

double 8字节  双精度

字符

char 2字节(16位) 

布尔

boolean 1字节  true false

引用类型

    

枚举

数组

接口

基本类型从小到大的顺序:顺序:byte-short-int-long-float-double

char比int小,和short,byte之间互相需要强制转换

java对byte,short,char三种类型做了特殊处理,允许直接赋不超过范围的int直接量




猜你喜欢

转载自blog.csdn.net/wkztselina/article/details/71429834