Add the chapter of hash map.

This commit is contained in:
Yudong Jin
2022-12-05 02:37:16 +08:00
parent 6c89c2b1cb
commit bc2561fb51
9 changed files with 385 additions and 5 deletions

View File

@ -91,4 +91,16 @@ public class PrintUtil {
showTrunks(p.prev);
System.out.print(p.str);
}
/**
* Print a hash map
* @param <K>
* @param <V>
* @param map
*/
public static <K, V> void printHashMap(Map<K, V> map) {
for (Map.Entry <K, V> kv: map.entrySet()) {
System.out.println(kv.getKey() + " -> " + kv.getValue());
}
}
}