- 雙語版Java程序設計
- 何月順主編
- 379字
- 2018-12-27 20:14:14
3.11 Record
When a number of data items are chunked together into a unit, the result is a data structure. Data structures can have very complex structure, but in many applications, the appropriate data structure consists simply of a sequence of data items. Data structures of this simple variety can be either arrays or records.
The term “record” is not used in Java. A record is essentially the same as a Java object that has instance variables only, but no instance methods. Some other languages, which do not support objects in general, nevertheless do support records. The C programming language, for example, is not object-oriented, but it has records, which in C go by the name “struct.” The data items in a record —in Java, an object’s instance variables—are called the fields of the record. Each item is referred to using a field name. In Java, field names are just the names of the instance variables. The distinguishing characteristics of a record are that the data items in the record are referred to by name and that different fields in a record are allowed to be of different types. For example, if the class Person is defined as:
record在Java中沒有被使用。本質上講,一個記錄與Java中的對象實例是一樣的,但是它沒有實例的方法。在Java中,字段名正好就是實例變量的名字。區分一個記錄中的字段是通過記錄中的數據項名字來實現的,并且記錄中不同的字段允許有不同的類型。
class Person { String name; int id_number; Date birthday; int age; }
then an object of class Person could be considered to be a record with four fields. The field names are name, id_number, birthday, and age. Note that the fields are of various types: String, int, and Date.
Because records are just a special type of object, I will not discuss them further.
- JavaScript實例自學手冊
- Getting Started with Clickteam Fusion
- Learning Apache Spark 2
- HBase Design Patterns
- 精通Excel VBA
- Hands-On Cybersecurity with Blockchain
- Linux內核精析
- 大數據導論
- 計算智能算法及其生產調度應用
- RealFlow流體制作經典實例解析
- Deep Learning Essentials
- DynamoDB Applied Design Patterns
- Flash CS5二維動畫設計與制作
- Keras Reinforcement Learning Projects
- 數據庫技術:Access 2003計算機網絡技術