Home [Data Sturcture] HashSet vs HashMap vs LinkedHashMap
Post
Cancel

[Data Sturcture] HashSet vs HashMap vs LinkedHashMap

HashSet πŸ†š HashMap


πŸ“Œ Let’s compare

Β HashSetHashMap
ImplementsSet InterfaceMap Interface
DataObjects<Key,Value>
Duplicate elementsNoKey : No
Values : Yes
Null elementsOnly oneKey : Only one
Values: multiple
Insertion methodadd(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

Screen Shot 2021-10-25 at 5 44 07 PM

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

HashMap

Screen Shot 2021-10-25 at 5 46 24 PM

Screen Shot 2021-10-25 at 5 46 36 PM

Screen Shot 2021-10-25 at 5 46 46 PM

Screen Shot 2021-10-25 at 5 46 57 PM

Screen Shot 2021-10-25 at 5 47 12 PM

Screen Shot 2021-10-25 at 5 47 23 PM

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

This post is licensed under CC BY 4.0 by the author.

[Algorithm] Longest Substring Without Repeating Characters

[Algorithm] Longest Palindromic Substring

Comments powered by Disqus.