Getting a new iterator object containing values from the Map(values method)
Now, we are going to have a look at a method, with which, we can get an iterator object, which contains the values for each element in the map object in the insertion order. The method that we are going to have a look at right now, is the values() method. Have a look at the below program, where we are trying to get the values for each element in the map.
If we try to have a look at the output, this is what we are going to get –
As you can see, we are getting an iterable object, containing the values from the Map.