Format the Java codes with the Reat Hat extension.

This commit is contained in:
krahets
2023-04-14 00:12:10 +08:00
parent 7273ee24e8
commit f8513455b5
39 changed files with 195 additions and 205 deletions

View File

@ -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);
}
}