且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么 Java 原始数据类型不称为 Java 数据类型?

更新时间:2023-01-01 09:56:21

因为 Java 有更多的数据类型,而不仅仅是 原语.原始数据类型是:

Because Java has more data types than just primitives. The primitive data types are:

  • 字节
  • int
  • 浮动
  • double
  • 布尔值
  • char

非原始数据类型是引用数据类型,它是对 对象.

A data type that is a non-primitive is a reference data type, which are references to objects.

一些例子是:

  • 字符串
  • 整数
  • ArrayList
  • 随机
  • JFrame

以下是两种类型区别的简单示例:

Here is a simple example of the difference between the two types:

int i1 = 10;
Integer i2 = Integer.valueOf(10);

int i1 是原始数据类型 int 的变量,原始数据类型 int 值为 10.

int i1 is a variable of the primitive data type int, with the primitive int value of 10.

Integer i2 是一个引用数据类型为 Integer 的变量,引用一个包含值 10Integer 对象/代码>.

Integer i2 is a variable with a reference data type of Integer, referencing an Integer object which contains the value 10.