InterviewSolution
| 1. |
Why Does Map Interface Not Extend The Collection Interface In The Java Collections Framework? |
|
Answer» The map interface is not compatible with the Collection interface. Because Map REQUIRES key as well as value, for example: if we want to add key-value pair so we will use PUT(OBJECT key , Object value). There are two parameters required to add an element to HashMap object. In Collection interface add(Object o) has only ONE parameter. The map interface is not compatible with the Collection interface. Because Map requires key as well as value, for example: if we want to add key-value pair so we will use put(Object key , Object value). There are two parameters required to add an element to HashMap object. In Collection interface add(Object o) has only one parameter. |
|