Java – LinkedHashMap signature

Looking at the JDK source code of LinkedHashMap, I notice that this class is declared as:

public class LinkedHashMap<K,V>
       extends HashMap<K,V>
       implements Map<K,V>
   {...

Why "implement Map < K, V >" (because HashMap has implemented map)? I can't imagine it's a typo

thank you.

Solution

I think this is a statement

If the person in charge of HashMap decides not to implement the map interface, the compiler will warn the maintainer of LinkedHashMap that it will no longer implement the map interface according to his intention

Of course, in this particular case, this is stupid (HashMap is obviously always a map), but similar situations may benefit from (and have produced) such conventions

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>