一、概念
Java基本类型共有八种
1、 字符类型:char
2、布尔类型:boolean
3、数值类型:byte、short、int、long、float、double
数值类型:
- 整数类型:
byte、short、int、long
- 浮点数类型:
float、double
注:在JAVA的数值类型中是不存在无符号的,其取值范围是固定的,不会因机器硬件环境、操作系统等原因更改而更改。
JAVA中还存在另外一种基本类型void,它对应着包装类 java.lang.Void,但无法直接对其进行操作。
二、各种数据类型的表示范围
数据类型 | 字节 | 最大存储数据量 | 数据范围 |
---|---|---|---|
byte | 1 byte | 255 | -128~127 |
short | 2 bytes | 65536 | -32768~32767 |
int | 4 bytes | 2^32-1 | -231~231 - 1 |
long | 8 bytes | 2^64-1 | -2^63~ 2^63 -1 |
float | 4 bytes | 3.4e-45~1.4e38 | IEEE754 |
double | 8 bytes | 4.9e-324~1.8e308 | IEEE754 |
boolean | 1 byte | true和false | |
char | 2 bytes | \u0000(即为0)~最 \uffff(即为65,535); |