7 Replies Latest reply: Jun 6, 2007 12:15 AM by 807606 RSS

    Why extends HashMap and implements Map?

    807606
      Hi,
      I browsed the source of HashMap in JDK 5.0.
      The declaration of the class puzzled me.

      Declaration of HashMap:
      public class HashMap<K,V>
          extends AbstractMap<K,V>
          implements Map<K,V>, Cloneable, Serializable
      Declaration of AbstractMap:
      public abstract class AbstractMap<K,V> implements Map<K,V>
      Puzzle:
      Now that AbstractMap has been declared to implement Map interface, and HashMap extends AbstractMap,
      why HashMap is declared to implement Map interface again?
      I don't think that's necessary.

      a cup of Java, cheers!
      Sha Jiang