Iterate hashmap in java
Example package com.w3schools; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; public class Test { public static void main(String args[]){ //Create HashMap object. Map<Integer, String> hashMap = new HashMap<Integer, String>(); //Add objects to the HashSet. hashMap.put(4, "Roxy"); hashMap.put(2, "Sunil"); hashMap.put(5, "Sandy"); hashMap.put(1, "Munish"); hashMap.put(3, "Pardeep"); //Print the HashMap object. System.out.println("HashMap elements:"); … Read more