package com.jet;import java.util.*;publicclassAbstractFactory{publicstaticvoidmain(String[] args){// Creating a HashMap of int keys and String values
Map<Integer, String> map =newHashMap<>();// Adding key and value pairs to map
map.put(1,"Deng");
map.put(2,"jet5devil");
map.put(4,"zero.dengc@outlook.com");// Getting a set of key-value pairs
Set entrySet = map.entrySet();// Obtaining an iterator for the entry set
Iterator in = entrySet.iterator();// First method: Iterator though map entries(key-value pairs)while(in.hasNext()){
Map.Entry entry =(Map.Entry) in.next();
System.out.println("Key = "+ entry.getKey()+", Value = "+ entry.getValue());}// Second method: foreach out result use map's entrySet()for(Map.Entry<Integer, String> entry : map.entrySet()){
System.out.println("Key = "+ entry.getKey()+", Value = "+ entry.getValue());}}}