HashSet π HashMap
π Letβs compare
| Β | HashSet | HashMap |
|---|---|---|
| Implements | Set Interface | Map Interface |
| Data | Objects | <Key,Value> |
| Duplicate elements | No | Key : No Values : Yes |
| Null elements | Only one | Key : Only one Values: multiple |
| Insertion method | add(Object) | put(Key, Value) |
| Advantage | - There are no duplicate elements in HashSet | - Itβs faster than HashSet |
The source : https://javaconceptoftheday.com/differences-between-hashmap-vs-hashset-in-java/
π Methods in Java
HashSet

The source : https://docs.oracle.com/javase/8/docs/api/java/util/HashSet.html
HashMap






The source : https://docs.oracle.com/javase/8/docs/api/java/util/HashMap.html
HashMap π LinkedHashMap
π Letβs compare
- LinkedHashMap ; the keys are ordered when put
- HashMap : the keys are not ordered when put
The source : https://fruitdev.tistory.com/141
Comments powered by Disqus.