XML Feeds

.

[java-dev] Re: perils of referencing

jbmaxwell jbmaxwell at rubato-music.com
Thu Feb 7 14:42:49 MST 2008


Oh yeah, jeepers... You're right. A deep copy would copy all the Things in the ArrayList, as well, wouldn't it! I just want a copy of the ArrayList itself. Good point.

I don't know if I'll change my accessor method, but I get the idea.

Is it possible to do something like:

ArrayList theseThings = bigThing.getThings().clone();

That would leave my accessor method getThings() untouched, and a bit more efficient for most situations.

J.

--------------

Thanks Ollie.

It does make sense to me, actually, but I like to get confirmation on things before I commit them to the "learned" pile... Passing references around is generally really handy, so I suppose it's not fair of me to complain about it now! ;-)

cheers.

 


More information about the java-dev mailing list