java - 理论-Java-抽象数据类型和引用数据类型

标签 java reference abstract language-lawyer primitive

“抽象数据类型”和“引用数据类型”的概念是否指同一事物,因此与“原始数据类型”对立使用?

谢谢!

最佳答案

传统上,“Abstract Data Type ”(另请参见 this definition )用于指定“类”的抽象概念。维基百科说:

Abstract data types are purely theoretical entities, used (among other things) to simplify the description of abstract algorithms, to classify and evaluate data structures, and to formally describe the type systems of programming languages. However, an ADT may be implemented by specific data types or data structures, in many ways and in many programming languages; or described in a formal specification language. ADTs are often implemented as modules: the module's interface declares procedures that correspond to the ADT operations, sometimes with comments that describe the constraints. This information hiding strategy allows the implementation of the module to be changed without disturbing the client programs.

特别是,数字数据类型,无论是原始类型还是引用类型,都是“抽象数据类型”的实例。

Java Language Specification使用第 4.1 章中的“原始数据类型/值”和“引用数据类型/值”一词:

4.1 The Kinds of Types and Values

There are two kinds of types in the Java programming language: primitive types (§4.2) and reference types (§4.3). There are, correspondingly, two kinds of data values that can be stored in variables, passed as arguments, returned by methods, and operated on: primitive values (§4.2) and reference values (§4.3).

但是,“抽象数据类型”一词从未被使用过,这是有充分理由的。

关于java - 理论-Java-抽象数据类型和引用数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24782590/

相关文章:

python - 如何为 Django 中的所有模型编写 __str__ 方法的通用实现?

java - 用户定义的 CORBA 异常在编译后给我错误

java - 如何为相同的用户标识选择相同的颜色

java - 我们是否需要关闭 ExecutorService fixedThreadPool

c++ - 将对 const 指针的引用从指向非 const 的指针定位

.net - 如何禁止引用 .NET DLL 类库

Java-静态变量,但扩展子类不共享该值

java - 两个连续的代码块 {}{} 有什么作用?

C++ 通过引用传递对象

java - 抽象方法错误