Why does LinkedHashSet<E> extend HashSet<e> and implement Set<E>

collections, hashtable, java

Solution

I've asked Josh Bloch, and he informs me that it was a mistake. He used to think, long ago, that there was some value in it, but he since "saw the light". Clearly JDK maintainers haven't considered this to be worth backing out later.

Problem

Opened a LinkedHashSet source code today and found some interesting thing: ``` public class LinkedHashSet<E> extends HashSet<E> implements Set<E>, Cloneable, java.io.Serializable { ``` The question is: why do they need both "extends HashSet" and "implements Set" when HashSet already is the Set?

Original source