Looking at the JDK source code for LinkedHashMap, I noticed that this class is declared as:
public class LinkedHashMap<K,V>
extends HashMap<K,V>
implements Map<K,V>
{...
why the redundant "implements Map<K,V>
" (since HashMap
already implements Map
) ? I cannot imagine this is a typo...
Thanks.
I suppose it's a way of saying
No matter what interfaces HashMap implements (now or in the future), this class should implement the Map interface.
If someone responsible for the HashMap decides that it should no longer implement the Map interface, the compiler will warn the maintainer of LinkedHashMap that it no longer implements the Map interface as he intended.
Of course it's silly in this particular case (HashMap will obviously always be a Map), but similar situations may benefit from (and have given rise to) such convention.
It's ancient code. Up to some point around JDK 1.1.6 or so, Javadoc didn't show inherited interfaces, so it was customary or indeed necessary to reiterate them in derived classes to get the Javadoc to work right. They were introduced in JDK 1.2 but were available well before that as an add-on for 1.1.x.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With