Java Reference
In-Depth Information
the entry within the collection. So even though the collection contains a clone of the client's origi-
nal object, getEntry would give the client access to the clone. Thus, it is necessary for getEntry to
return a clone of the desired entry. This is a clone of the clone of the client's original object, as
Figure 30-13 shows.
FIGURE 30-11
A collection and its client after the clone of an object is added to
the collection
An object
Clone of the object
newEntry
A client of a collection
A collection
FIGURE 30-12
The effect of getEntry if it did not return a clone
An object
Clone of the object
newEntry
Reference that
getEntry returns
A client of a collection
A collection
FIGURE 30-13
The effect of getEntry when it returns a clone
Clone of the object
An object
newEntry
Reference that
getEntry returns
Clone of the clone
A client of a collection
A collection
Search WWH ::




Custom Search