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.
source
share