Java / Map and its implementations
Why Map does not extend the Collection interface in Java Collections Framework?
Map interface is not compatible with the Collection interface.
Since Map requires key as well as value , for example, if we want to add key-value pair then we will use put(Object key, Object value). So there are two parameters required to add element to the HashMap object . In Collection interface add(Object o) has only one parameter.
Map supports valueSet , keySet as well as other appropriate methods which have just different views from the Collection interface.
More Related questions...