wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes duplicates in collection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "duplicates in collection" Watch "duplicates in collection" New topic

duplicates in collection

Barkat Mardhani
Ranch Hand

Joined: Aug 05, 2002
Posts: 787
Q. From following interfaces/class, identify ones that do not allow duplicates?
The answer given is Map and Set. Why Map?
Alton Hernandez
Ranch Hand

Joined: May 30, 2003
Posts: 443
Perhaps because Map does not allow duplicate keys.
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
map cares about unique identifiers.
set does not allow duplicates.

I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
Alton Hernandez
Ranch Hand

Joined: May 30, 2003
Posts: 443
From the Java API Doc:

A map cannot contain duplicate keys; each key can map to at most one value.
It is sorta covered in the JavaRanch Style Guide.
subject: duplicates in collection
Similar Threads
how to put duplicate keys in a hashmap
Collection question
Map: no duplicates allowed?
HashMap/Tree map question