import java.util.*; public class OutputMapIndividually // demonstrates how to obtain each entry in a map { public static void main(String[] args) { HashMap map=new HashMap<>(); // our map Random g=new Random(); // we'll random generate keys and values String temp; // values will be Strings int value, i, j; // each String will be a random length, stored in value, i and j are loop indices char c; // the next character generated (randomly) for(i=0;i<10;i++) // generate 10 key-value pairs { value=g.nextInt(6)+3; // generate a string of 3-8 characters temp=""; // start String as empty for(j=0;j> list=map.entrySet(); // this obtains all of the entries in the map as an iterable object for(Map.Entry item: list) // iterate for each Map.Entry in list System.out.println(item.getKey() + "\t" + item.getValue()); // output each entry's key and value // System.out.println(item); // we could also output the keys and values this way } // which would give us notation like 314=abcdef } /* sample output {305=aiflaei, 237=mvtmooqf, 985=fckawiu, 415=rgd, 720=vfad, 602=dgrnp, 215=aiqhnazh, 675=pvbqyutu, 824=pfxs, 674=oprwrf} 305 aiflaei 237 mvtmooqf 985 fckawiu 415 rgd 720 vfad 602 dgrnp 215 aiqhnazh 675 pvbqyutu 824 pfxs 674 oprwrf */