Possible Duplicate:
Java.util.HashMap — why HashMap extends AbstractMap and implement Map?
In java to implement HashMap<K,V>
we need to implement Map<K,V>
.
However when I debugged more in java classes it seems that.... java defines HashMap
class as following.
public class HashMap<K,V>
extends AbstractMap<K,V>
implements Map<K,V>, Cloneable, Serializable
At the same time i saw public abstract class AbstractMap<K,V>
implements Map<K,V>
it also implements the interface Map<K,V>
.
If abstract class implements the interface then, what is the reason behind implementing Map<K,V>
at HashMap
class level?
As per my understanding HashMap
class have all the methods inherited from AbstractMap
which can be overridden by HashMap
as per the requirement.