Java Reference
In-Depth Information
Mutable,
Immutable, and
Cloneable Objects
Chapter
30
Contents
Mutable and Immutable Objects
Creating a Read-Only Class
Companion Classes
Cloneable Objects
Cloning an Array
Cloning a Chain
A Sorted List of Clones
Prerequisites
Appendix C
Creating Classes from Other Classes
Appendix E
Exception Handling
Chapter
13
List Implementations That Use Arrays
Chapter
14
A List Implementation That Links Data
Chapter
15
Iterators
Chapter
16
Sorted Lists
Chapter
17
Inheritance and Lists
Objectives
After studying this chapter, you should be able to
Distinguish among mutable and immutable objects
Define a class of immutable objects
Define companion classes, one of immutable objects and the other of mutable objects
Define a method clone for a given class
Clone an array or chain of objects
Implement a collection such as a sorted list that clones the objects added to it
W hen a class has public mutator, or set, methods, a client can use these methods to
alter objects of that class. Although this ability seems reasonable, it is unreasonable if
 
Search WWH ::




Custom Search