// Traditional method 1
Map map = new linkedhashmap ();
Map. Put (1, "Zhang San ");
Map. Put (2, "Li Si ");
Map. Put (3, "Wang Wu ");
Set set = map. keyset ();
Iterator = set. iterator ();
While (iterator. hasnext ()){
Int key = (integer) iterator. Next ();
String value = (string) map. Get (key );
System. Out. println (value );
}
// Traditional method 2
Map MAP2 = new linkedhashmap ();
Map2.put ("1", "Zhang San ");
Map2.put ("2", "Li Si ");
Map2.put ("3", "Wang Wu ");
Set set2 = map2.entryset ();
Iterator iterator2 = set. iterator ();
While (iterator2.hasnext ()){
Map. Entry entry = (entry) iterator2.next ();
String key = (string) entry. getkey ();
String value = (string) entry. getvalue ();
System. Out. println (Key + "=" + value );
}
// Enhance the for loop method 1
Map map3 = new linkedhashmap ();
Map3.put ("1", "Zhang San ");
Map3.put ("2", "Li Si ");
Map3.put ("3", "Wang Wu ");
For (Object OBJ: map3.keyset ()){
String key = (string) OBJ;
String value = (string) map3.get (key );
}
// Method 2 of the For Loop Enhancement
Map map4 = new linkedhashmap ();
Map4.put ("1", "Zhang San ");
Map4.put ("2", "Li Si ");
Map4.put ("3", "Wang Wu ");
For (Object OBJ: map4.entryset ()){
Map. Entry entry = (entry) OBJ;
String key = (string) entry. getkey ();
String value = (string) entry. getvalue ();
}