Below is the sample output when you run the above example.
There would be two output on the console when you try to run the provided example. First, the initial value of key-value mapping were printed and the next one are the new set of key-value mapping after we added additional key-value mapping on our HashMap. At first glance this is a straightforward example but did you notice that we have not invoked the entrySet after we have put additional key on our HashMap and yet the new key were added to the mappingSet. This is the inherent behavior of entrySet() method when you modify the HashMap object the Set would also be modified. The Set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.