Link to home
Start Free TrialLog in
Avatar of Manikandan Thiagarajan
Manikandan ThiagarajanFlag for India

asked on

Difference between Map and Set

Difference between Map and Set
SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Manikandan Thiagarajan

ASKER

>>A Set is simply a container for unique objects

could you explain this one
Think of it as a list that can only contain unique objects as dictated by their equals method
Avatar of olgavillamizar
olgavillamizar

A map has a pair for example
(key, object).
With key you can get the object

A set is just the object (object) just one.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>Set s = new HashSet ( al ) ;

so this would avoid the duplicate values in array list
The array list will still contain those duplicates, the set will not.
:-)