Interview Question
Both are part of Java Collection Framework.
1) HashMap is derived from Map Interface. Map is nothing but key-value pair as in HashTable. HashMap key-value ordering is random.
2) HashSet is derived from Set Interface which is derived from Collection Interface.
Any set interface do not allow duplicate elements. Hashset value ordering is random.
1) HashMap implements the Map interface. HashSet implements the Set interface.
- badalrocks January 29, 20092) In HashSet you use only one Object to search or insert. In HashMap, you use two objects (key-value) to insert.