7 Replies Latest reply on Jun 6, 2007 5:15 AM by 807606

    Why extends HashMap and implements Map?

      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>
      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