In a previous article, "Peter Duniho" <NpOeStPeAdM@[EMAIL PROTECTED]
> said:
>"yes", that's not the answer to the question in the subject. Objects
>_aren't_ "deep copied" when added to a collection. They aren't even
>"shallow copied". Only the reference to the object is copied to the
>collection. The object isn't copied at all, deep or otherwise.
The great thing about that is that the cost of adding an object to a
collection or map is pretty minuscule (probably only 4 or 8 bytes). So if
you might need to access the same object in two different orders, it's not
a big deal to make two TreeSets with different Comparators, rather than
re-sorting the same collection every time you need it in a different
order, or having multiple Maps with different keys.
--
Paul Tomblin <ptomblin@[EMAIL PROTECTED]
> http://blog.xcski.com/
"Dad, I left my heart up there."
-- Francis Gary Powers after his first flight (age 14)


|