• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

remove method?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic