1

Possible Duplicate:
Why does the java.util.Set<V> interface not provide a get(Object o) method?

Why Java sets don't have methods for retrieving an element that is equal to provided?

For example, I need to create an object pool, something like String.intern() method (yes, I know that this is usually done with weak references), so I need to create a Map and do map.put(o,o) to put my unique object if they are not present in the map. But a set is more appropriate in this case I think.

Community
  • 1
  • 1
Anton Kazennikov
  • 3,574
  • 5
  • 30
  • 38

0 Answers0