Java EnumMap with Example

Java EnumMap is a Java Map that uses keys of a single enum type. EnumMap utilizes the inherent associative nature of arrays and is therefore the most efficient implementation of Map.  In a nutshell, EnumMap is a one-trick-pony designed to be used when the keys of your Map are constants and therefore can be made static and final. Constructors of EnumMap… Continue reading Java EnumMap with Example

Java HashMap with Example

Java HashMap is the most popular concrete implementation of Java Map. The distinguishing feature of HashMap is that it is based on the celebrated hashtable data structure. Like any other Java Map, a HashMap maintains associations between keys and values. A HashMap is an unordered collection, meaning you should not use HashMap if your program requires iteration or retrieval in a predictable order. Nevertheless, a HashMap is extremely efficient… Continue reading Java HashMap with Example