mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-07 15:01:58 +08:00
Format the Java codes with the Reat Hat extension.
This commit is contained in:
@ -16,9 +16,9 @@ public class hash_map {
|
||||
|
||||
/* 添加操作 */
|
||||
// 在哈希表中添加键值对 (key, value)
|
||||
map.put(12836, "小哈");
|
||||
map.put(15937, "小啰");
|
||||
map.put(16750, "小算");
|
||||
map.put(12836, "小哈");
|
||||
map.put(15937, "小啰");
|
||||
map.put(16750, "小算");
|
||||
map.put(13276, "小法");
|
||||
map.put(10583, "小鸭");
|
||||
System.out.println("\n添加完成后,哈希表为\nKey -> Value");
|
||||
@ -37,15 +37,15 @@ public class hash_map {
|
||||
|
||||
/* 遍历哈希表 */
|
||||
System.out.println("\n遍历键值对 Key->Value");
|
||||
for (Map.Entry <Integer, String> kv: map.entrySet()) {
|
||||
for (Map.Entry<Integer, String> kv : map.entrySet()) {
|
||||
System.out.println(kv.getKey() + " -> " + kv.getValue());
|
||||
}
|
||||
System.out.println("\n单独遍历键 Key");
|
||||
for (int key: map.keySet()) {
|
||||
for (int key : map.keySet()) {
|
||||
System.out.println(key);
|
||||
}
|
||||
System.out.println("\n单独遍历值 Value");
|
||||
for (String val: map.values()) {
|
||||
for (String val : map.values()) {
|
||||
System.out.println(val);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user