Quickest implementation of Java Map for a small number of entries

前端 未结 3 1596
遇见更好的自我
遇见更好的自我 2021-02-13 13:15

What is the quickest implementation of java.util.Map for a very small number of entries (under 15 elements or so)? Both thread-safe and non-thread-safe.

3条回答
  •  心在旅途
    2021-02-13 13:24

    I'd say HashMaps.

    HashMap map = new HashMap ();

    will give you a very simple map with a key type of String and Value type of Object.

    Edit: This is a non-thread safe version.

    You can check out ConcurrentHashMaps for a thread-safe map.

提交回复
热议问题