When removing an element in collection, we can use Collection interface's remove(Object) or get a Iterator from that collection, then use Iterator's remove() method. But What��s the difference between these two method? Are there efficiency or security differences? Thanks for any help.
xallan, We get a surprizing number of users with similar names. That's why we have established and enforce a Naming Policy It can benifit you, read Book Giveaway Page The main difference is if you have created an Iterator or not on the collection. If you havn't then the Iterators remove method isn't available to you. If you have and you use the Colections remove method, the next time you try and access the Iterator, you get an IllegalStateException. The Iterator now points to more elements then are in the Collection.
------------------ Hope This Helps Carl Trusiak, SCJP2 [This message has been edited by Carl Trusiak (edited April 23, 2001).]
Thanks. I changed my username for winning a free book. From your reply, I think the idea is I shouldn't mix two kinds of remove method. But another question: Which one is better in efficiency and security? Best Regards.