- 网络数据采集技术:Java网络爬虫实战
- 钱洋等
- 397字
- 2025-02-17 21:43:45
2.2 基本数据类型
在Java中,共有8种基本数据类型,即byte、short、int、long、float、double、boolean和char。其中,byte、short、int和long为整数类型,float和double为浮点类型,boolean为逻辑类型,char为字符类型。
byte数据类型,内存分配1字节,1字节由8位组成,最大值为27-1,最小值为-27,下面为byte变量声明方式。

short数据类型,内存分配2字节,占16位,最大值为215-1,最小值为-215,下面为short变量声明方式。

int数据类型,内存分配4字节,占32位,最大值为231-1,最小值为-231,下面为int变量声明方式。

long数据类型,内存分配8字节,占64位,最大值为263-1,最小值为-263,下面为long变量声明方式。

float数据类型,符合IEEE754标准的浮点数,内存分配4字节,占32位,下面为float变量声明方式。

double数据类型,符合IEEE754标准的浮点数,内存分配8字节,占64位,下面为double变量声明方式。

boolean数据类型,只有两个取值,即true和false,下面为boolean变量声明方式。

char数据类型,即字符类型,内存分配2字节,是1个单一的16位Unicode字符,下面为char变量声明方式。
