Skip to content

Commit e38440b

Browse files
committed
add HashMap Entry Test
1 parent b27f368 commit e38440b

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

java_test/src/main/java/com/yiyun/TesthashMap.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,24 @@
77

88
public class TesthashMap {
99
@Test
10-
public void fun(){
10+
public void fun1() {
1111
Map<Integer, String> map = new HashMap<>();
12-
map.put(1,"yiyun1");
13-
map.put(2,"yiyun2");
14-
map.put(3,"yiyun3");
15-
map.put(4,"yiyun4");
12+
map.put(1, "yiyun1");
13+
map.put(2, "yiyun2");
14+
map.put(3, "yiyun3");
15+
map.put(4, "yiyun4");
1616
System.out.println("map = " + map);
1717
}
18+
19+
@Test
20+
public void fun2() {
21+
Map<Integer, String> map = new HashMap<>();
22+
map.put(1, "yiyun1");
23+
map.put(2, "yiyun2");
24+
map.put(3, "yiyun3");
25+
map.put(4, "yiyun4");
26+
for (Map.Entry<Integer, String> entry : map.entrySet()) {
27+
System.out.println("键" + entry.getKey() + ":" + entry.getValue());
28+
}
29+
}
1830
}

0 commit comments

Comments
 (0)