File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

remove method?

 
xallan
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Carl Trusiak
Sheriff
Posts: 3340
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Allan Wang
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic