I. Common public static void work (Map <string, student> map) {collection <student> C = map. values (); iterator it = C. iterator (); For (; it. hasnext ();) {system. out. println (it. next () ;}} II: // use keyset for traversal. Its advantage is that it can be worth the values you want based on the key you want, with a little flexibility !!
Public static void workbykeyset (Map <string, student> map) {set <string> key = map. keyset (); For (iterator it = key. iterator (); it. hasnext ();) {string S = (string) it. next (); system. out. println (map. get (s) ;}}3: a complex Traversal method with high flexibility: public static void workbyentry (Map <string, student> map) {set <map. entry <string, student> set = map. entryset (); For (iterator <map. entry <string, student> it = set. iterator (); it. hasnext ();) {map. entry <string, student> entry = (map. entry <string, student>) it. next (); system. out. println (entry. getkey () + "--->" + entry. getvalue ());}}}