@Test public void TestMap () {map<integer,string> map=new hashmap<> ();
Map.put (1, "AA");
Map.put (2, "BB");
Map.put (3, "CC");
StringBuffer str=new StringBuffer ();
The first method for (map.entry<integer,string> Entry:map.entrySet ()) {Integer key=entry.getkey ();
String Value=entry.getvalue ();
Str.append (key+ "_" +value+ ");
} System.out.println (str);
The second method str.append ("\ n");
Iterator It=map.entryset (). iterator ();
while (It.hasnext ()) {map.entry m= (map.entry) it.next ();
Object Key=m.getkey ();
Object Value=m.getvalue ();
Str.append (key+ "_" +value+ ");
} System.out.println (str);
The third method str.append ("\ n");
For (iterator It1=map.keyset (). iterator (); It1.hasnext ();) {Object key=it1.next ();
Object Value=map.get (key); Str.apPend (key+ "_" +value+ ");
} System.out.println (str);
The fourth method Str.append ("\ n");
For (object Key:map.keySet ()) {Object Value=map.get (key);
Str.append (key+ "_" +value+ ");
} System.out.println (str); }