Map<Character, String> charType
= new HashMap<Character, String>();
// Inserting data in the hash map.
charType.put('J', "Java");
charType.put('H', "Hibernate");
charType.put('P', "Python");
charType.put('A', "Angular");
// Iterating HashMap through forEach and
// Printing all. elements in a Map
charType.forEach(
(key, value)
-> System.out.println(key + " = " + value));
// or
// using for loop to iterate the map entry sets
for (Map.Entry<String,String> mapElement : charType.entrySet()) {
String key = mapElement.getKey();
// Adding some bonus marks to all the students
String value = mapElement.getValue();
// Printing above marks corresponding to
// students names
System.out.println(key + " : " + value);
}