天天看点

【Java】8种基本类型(9种?)

Java类型大类:

1. 基本类型(或叫原生类、内置类型)

2. 引用类型

简图:

【Java】8种基本类型(9种?)
  1. 基本类型 8,9 种
序号 基本类型 大小 最小值 最大值 默认值 包装类 包装类默认值
1 boolean(布尔型) false Boolean null(下同)
2 char(字符型) 16-bit(2字节) Unicode 0 Unicode 2^16-1 ‘\u0000’(Unicode 0) Character
3 byte(字节型) 8 bits(1字节) -128 127 (byte)0 Byte
4 short(短整型) 16 bits(2字节) -2^15 2^15-1 (short)0 Short
5 int(整型) 32 bits(4字节) -2^31 2^31-1 Integer
6 long(长整型) 64 bits(8字节) -2^63 2^63-1 0L Long
7 float(浮点型) 32 bits(4字节) IEEE754 IEEE754 0.0F Float
8 double(双精度浮点型) 64 bits(8字节) IEEE754 IEEE754 0.0D Double
9 void(空类型) Void

2. 引用类型

序号 引用类型名称 默认值
1 null
2 接口 null
3 数组 null
4 枚举 null
5 注解 null

tips:

String 内部实现是char数组(char[]),默认值null(对象默认值都是null);

主要参考《Java编程思想》(Thinking In Java,第四版),第二章基本类型部分。

参考:

https://www.jianshu.com/p/6b36e911f1fd

https://www.cnblogs.com/bekeyuan123/p/7468845.html

https://blog.csdn.net/lucky123sky/article/details/54924411