Public class KeysetAndEntrySet {
Public static void main (String [] args ){
Map map1 = new HashMap ();
Map map2 = new TreeMap ();
Map1.put ("name1", "Christ Bosh ");
Map1.put ("name2", "Kobe Bryant ");
Map1.put ("name3", "Lebron James ");
Map1.put ("name4", "Dwany Wade ");
Map2.put ("name1", "Christ Bosh ");
Map2.put ("name2", "Kobe Bryant ");
Map2.put ("name3", "Lebron James ");
Map2.put ("name4", "Dwany Wade ");
Set set = map1.entrySet ();
Iterator it = set. iterator ();
While (it. hasNext ()){
Map. Entry next = (Entry) it. next ();
// System. out. println ("========" + next. toString () + "**********");
// String str = it. next (). toString ();
// Int index = str. indexOf ("= ");
// System. out. println (str. substring (0, index) + "" + str. substring (index + 1 ));
Object key = next. getKey ();
Object value = next. getValue ();
System. out. println (key + "++" + value );
}
System. out. println ("------------------------------------");
Set set2 = map2.keySet ();
Iterator it2 = set2.iterator ();
While (it2.hasNext ()){
Object ob = it2.next ();
System. out. println (ob. toString () + "" + map2.get (ob ));
}
}
}