Object-Oriented Programming
摘要
This chapter is divided into two halves. In the first half, we begin to introduce the basics of object-oriented programming.We start off simple with small classes that contain only immutable fields. The complexity gradually increases as we mix in mutability and aliasing. This chapter also describes the implementation of several data structures that mimic those from the Collections framework, including ArrayList, LinkedList, HashSet, and maps. In the second half, we expand on the details of object-oriented programming by describing interfaces and inheritance. Interfaces ascribe behaviors and characteristics to classes, whereas inheritance denotes “IS-A” relationships across classes. We conclude the chapter by demoing a practical application of object-oriented programming and class design by writing a small programming language.