Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Why does Map interface not extend Collection interface in Java?

Pragya Keshap answered on February 4, 2023 Popularity 3/10 Helpfulness 1/10

Contents


More Related Answers

  • map interface
  • how to instanciate map.entry java

  • Why does Map interface not extend Collection interface in Java?

    0

    A Map is a collection objects. But Map interface is not compatible

    with Collection interface in Java.

    A Map requires key as well as a value. So it requires two

    parameters to add an element to a HashMap.

    But Collection interface provides add(Object o) method with only

    one parameter.

    Map collection has to provide methods like valueSet, keySet etc.

    These methods are specific to Map collection. Where as methods in

    Collection interface can be reused by a List, Set, Queue etc.

    https://agrawalsuneet.github.io/blogs/why-map-does-not-extend-collection-interface/

    Popularity 3/10 Helpfulness 1/10 Language java
    Source: Grepper
    Link to this answer
    Share Copy Link
    Contributed on Feb 04 2023
    Pragya Keshap
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.