List vs Map in Java

前端 未结 9 1880
灰色年华
灰色年华 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:54

    When you want to map instead of list. The names of those interfaces have meaning, and you shouldn't ignore it.

    Use a map when you want your data structure to represent a mapping for keys to values. Use a list when you want your data to be stored in an arbitrary, ordered format.

提交回复
热议问题