| Define Map and their types in Java?
In Java Map is an object that helps to maps keys with values. And this will not contain duplicate keys and every key is map to only one value. And to check the two keys are same or distinct we use a equals() method. There are four types of map in Java as given below:-
(1)HashMap:-HashMap is an unordered and unsorted map so it is a good choice when there is no emphasis on the order. A HashMap allows one null key and multiple null values and doesn't maintain any insertion order.
(2)HashTable:-This will not allow anything null and has methods that are synchro/nized. And it allows for thread safety and performance is very slow.
(3)LinkedhashMap:-It is much slower then HaspMap but it maintains inseration order and has a faster iteration.
(4)TreeMap:-A sorted Map providing support for constructing a sort order using a constructor. | | |