Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5980051

Browse files
update HashMapDemo.java
1 parent 2a6c2d1 commit 5980051

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/DGenericContainer/Map_HashMap/HashMapDemo.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package DGenericContainer.Map_HashMap;
22

3+
import java.util.ArrayList;
34
import java.util.HashMap;
5+
import java.util.List;
6+
import java.util.Map;
47

58
/**
69
* @author supremepole
@@ -17,5 +20,23 @@ public static void main(String[] args) {
1720
hashMap.clear();//删除所有的键值对
1821
hashMap.entrySet();//返回hashMap中所有映射项的集合视图
1922
hashMap.keySet();//返回hashMap中所有key组成的集合视图
23+
keySet();
24+
nullList();
25+
}
26+
27+
public static void keySet(){
28+
Map<String, String> map=new HashMap<>();
29+
map.put("key1", "value1");
30+
System.out.println(map.keySet());
31+
map.keySet().forEach(k->{
32+
System.out.println(k);
33+
});
34+
}
35+
36+
public static void nullList(){
37+
List<String> list=new ArrayList<>();
38+
String string=null;
39+
list.add(string);
40+
System.out.println(list.size());
2041
}
2142
}

0 commit comments

Comments
 (0)