On Tue, Apr 15, 2008 at 7:15 PM, Matthew Toseland <toad at amphibian.dyndns.org> wrote: > On Tuesday 15 April 2008 01:08, you wrote: > > On Tue, Apr 15, 2008 at 5:18 AM, Matthew Toseland > > <toad at amphibian.dyndns.org> wrote: > > > Umm, what do you think the synchronized() is for? Why lock an object, > then > > > clone it, then do something with the clone, and finally unlock? > > > > > > > r19281 fixed this without using a clone. > > The problem is, we can't remove any item while holding an > iterator/enumerator. > > Ok. PS why iterate over a vector? Surely it is more efficient to just use a > loop and get()? >
No much different on efficiency. And I think iterator is easier to understand In most cases, it make no much different. In some cases, such as LinkedList and TreeSet, iterator is much more efficient. That's why my brain is wired to use iterator.. Regards, Daniel Cheng
