Java中的8个基本数据类型

Java中的8个基本数据类型分别是byte, short , int , long ,float, double ,char, boolean.

byte, short, int, double, long, float是数值型。

char是字符型。

boolean是布尔型。

byte,short、int、long是整型。

double、float是浮点型。

8个基本数据类型的字节数

int(4字节)

byte(1字节)

short(2字节)

long(8字节)

float (4字节)

double(8字节)

char(2字节)

boolean(1byte)

基本数据类型不是对象,不能使用对象的方法。

基本数据类型的默认值仅在作为类中属性时生效在方法内部必须先对基本数据类型变量赋值后才能使用,否则编译不通过。

发表评论