Difference between EnumMap and HashMap in Java

HashMap vs EnumMap in Java
What is the difference between EnumMap and HashMap in Java is the latest Java collection interview question which has been asked to a couple of my friends? This is one of the tricky Java questions, especially if you are not very much familiar with EnumMap in Java, which is not uncommon, given you can use it with only Enum keys. The main difference between EnumMap and HashMap is that EnumMap is a specialized Map implementation exclusively for Enum as key. Using Enum as key allows doing some implementation level optimization for high performance which is generally not possible with other objects as key. We have seen a lot of interview questions on HashMap in our article How HashMap works in Java but what we missed there is this question which is recently asked to some of my friends. Unlike HashMap, EnumMap is not applicable for every case but it's best suited when you have Enum as key. We have already covered basics of EnumMap and some EnumMap example in my last article What is EnumMap in Java and In this post, we will focus on key differences between HashMap and EnumMap in Java.
Read more �

Comments

Popular posts from this blog

Cara Membuat Halaman Login Hotspot Berbeda pada 1 Mikrotik

UltraISO Premium Edition v9.5.3

Arti OSAKMJ