map in map java code example
Example 1: map in java
MAP : is a (key-value format)
and keys are always unique,
and value can be duplicated.
- HashTable don't have null key, sychronized(thread-safe)
- LinkedHashMap can have null key, keeps order
- HasHMap can have null key, order is not guaranteed
- TreeMap doesn't have null key and keys are sorted
Example 2: how to create a hashmap in java
HashMap<Integer,String> map=new HashMap<Integer,String>();//key is integer, value is String