Maybe I'm being picky, but in javadoc there is a following information about LinkedHashSet implementation:
This implementation differs from HashSet in that it maintains a doubly-linked list running through all of its entries.
I can't find any double-linked list in LinkedHashSet class. Can somebody help?
Yeah, it's a bit wonky when you look at the source without drilling down. Notice it calls that package protected HashSet constructor that takes a meaningless boolean called dummy:
That then uses a
LinkedHashMap
instead of aHashMap
to back the set. Effectively, LinkedHashSet is actually inside HashSet, it's just package protected so you have to use LinkedHashSet to get at it.