Problem in java.util.Set.addAll() method

Posted by Yatendra Goel on Stack Overflow See other posts from Stack Overflow or by Yatendra Goel
Published on 2010-04-16T12:36:48Z Indexed on 2010/04/16 12:43 UTC
Read the original article Hit count: 210

Filed under:
|

I have a java.util.Set<City> cities and I need to add cities to this set in 2 ways:

  • By adding individual city (with the help of cities.add(city) method call)

  • By adding another set of cities to this set (with the help of cities.addAll(anotherCitiesSet) method call)

But the problem in second approach is that i don't know whether there were any duplicate cities in the anotherCitiesSet.

I want to do some processing whenever a duplicate entry is tried to be entered in thecities set.

© Stack Overflow or respective owner

Related posts about java

Related posts about set