本书提供了《数据结构》(Java语言描述)课程中各章节练习题的答案和解析,帮助读者深入理解数据结构的概念及其在Java中的实现方法。
Exercise Solutions to Data Structures Outside in with Java By Hongbiao Zeng Chapter 1
E1.1.
a) Two states are frequency and volume, and two methods are set volume and get frequency.
b) Two states include length and text, with two methods being set text and get length.
c) The state consists of center and radius, along with the methods set center and get radius.
d) There are two states: names of two roads that intersect. Methods include getting road names and setting road names.
e) States involve car price and car mileages, while methods consist of setting price and getting mileages.
f) Two states are type and speed, alongside methods for setting type and obtaining speed.
E1.2
A static field is used to store a resource that can be shared by the entire class.
E1.3
Static methods serve as utility functions or control instance numbers. The special static method main acts as the entry point of a program.
E1.4
A static method cannot refer to non-static fields within its class because these non-static fields are tied to an instance of the class, whereas the static method can be invoked without any instances existing. Conversely, a non-static method is able to reference static fields since they are shared among all instances of the class.