Different Maps in JAVA
Published:
Chart
map name | Thread Safe | Read | Write | JDK Version | reference |
---|---|---|---|---|---|
HashMap | No | O(1) | O(1) | 1.2 | ref |
HashTable | Yes | O(1) | O(1) | 1.0 | ref |
synchronizedMap() | Yes | O(1) | O(1) | ref | |
ConcurrentSkipListMap | Yes | O(log(n)) | O(log(n)) | 1.6 | ref |
ConcurrentHashMap | Yes | O(1) | O(1) | 1.5 | ref |
EnumMap | No | O(1) | O(1) | 1.5 | ref |
IdentityHashMap | No | O(1) | O(1) | 1.4 | ref ref1 |
LinkedHashMap | No | O(1) | O(1) | 1.4 | ref ref1 |
TreeMap | No | O(log(n)) | O(log(n)) | 1.2 | ref ref1 |
WeakHashMap | No | O(1) | O(1) | 1.2 | ref ref1 |
FYI
Do prepare such a table, and when you plan to use the Map data structure, reference this table for your design.