InterviewSolution
| 1. |
How Hashset Store Elements? |
|
Answer» You must know that HASHMAP store key-VALUE pairs, with one condition i.e. keys will be unique. HashSet uses Map’s this FEATURE to ensure uniqueness of elements. In HashSet class, a map declaration is as below: private transient HashMap<E,Object> map; public boolean add(E e) You must know that HashMap store key-value pairs, with one condition i.e. keys will be unique. HashSet uses Map’s this feature to ensure uniqueness of elements. In HashSet class, a map declaration is as below: private transient HashMap<E,Object> map; public boolean add(E e) |
|