What is the difference between a HashSet and a LinkedHashSet

I saw that LinkedHashSetextends HashSet, and I know that it keeps order.
However, checking the code in the JDK, it seems that it LinkedHashSetcontains only a constuctor and no implementation, so I assume that all the logic happens in HashSet?
If this is correct, why is it created like this? it seems very confusing.

EDIT: There was a failed error in the question. I wrote HashMapand LinkedHashMapinstead of HashSetand LinkedHashSet. I set the answer to the question, if possible.
Also, I was wondering why the Java developers decided to implement it like this.

+1
source share
2 answers

, LinkedHashMap -. - init(), -.

LinkedHashMap - HashMap .

+1

, , LinkedHashMap HashMap, .

, HashMap HashMap, - removeEldestEntry(), , "" .

0

All Articles