The elements in a map are ordered which means that the elements can be iterated in the order they are inserted.
Example 1: In this example, we will create a new map object and iterate over it to check how the elements are ordered.
Key = name, Value=Rahul Key = age, Value=20 Key = Country, Value=India
Example 2: In this example, we will save the keys and values of the map in two different arrays
(3) ['name', 'age', 'Country'] (3) ['Rahul', 20, 'India']
Explanation: We can see that the elements maintain the order they are entered in the map so the insertion in new arrays follows the same order as that of the map
Please Login to comment...