As shown in java.util.*
, AbstractSet<E> implements Set<E>
, so why HashSet<E> extends AbstractSet<E> implements Set<E>
? Is the "implements Set<E>
" duplicated here?
Asked
Active
Viewed 74 times
5

Zhou Tai
- 214
- 1
- 10
2 Answers
2
This has been done to be able to override the javadoc documentation.
The javadoc for HashSet<E>
and AbstractSet<E>
differ for example.
It can also be done for more clarity.

skiwi
- 66,971
- 31
- 131
- 216
2
Yes it is duplicated, but I guess it is a coding style decision. I as well do prefer to explicitly implement the interfaces a type is motivated to be introduced for. The extends is just an implementation detail, most often motivated by reuse. Hence, the type which inherits from the base class will be stable even when removing the base class and implementing those functionality in some other way.

Harmlezz
- 7,972
- 27
- 35