List vs Map in Java

前端 未结 9 1864
灰色年华
灰色年华 2020-12-02 23:29

I didnt get the sense of Maps in Java. When is it recommended to use a Map instead of a List?

thanks in advance,

nohereman

9条回答
  •  自闭症患者
    2020-12-02 23:41

    A map is used as an association of a key and a value. With a list you have basically only values.
    The indexes in List are always int, whereas in Map you can have another Object as a key.


    Resources :

    • sun.com - Introduction to the Collections Framework, Map

提交回复
热议问题