为什么 Java 原始数据类型不称为 Java 数据类型? [英] Why aren't Java Primitive Data Types called java data types?
问题描述
我有一个问题,为什么不将 Java 原始数据类型称为Java 数据类型"或类似的名称?
I have a question, why aren't Java primitive data types just called "Java data types" or something similar?
推荐答案
因为 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
的变量,引用一个包含值 10<的
Integer
对象/代码>.
Integer i2
is a variable with a reference data type of Integer
, referencing an Integer
object which contains the value 10
.
这篇关于为什么 Java 原始数据类型不称为 Java 数据类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!