HashMap
is a Map
implementation, allowing duplicate values but not duplicate keys.. For adding an object a Key/Value pair is required. Null Keys and Null values are allowed. eg:
{The->3,world->5,is->2,nice->4}
HashSet
is a Set
implementation,which does not allow duplicates.If you tried to add a duplicate object, a call to public boolean add(Object o)
method, then the set remains unchanged and returns false
. eg:
[The,world,is,nice]