File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
src/DGenericContainer/Map_HashMap Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 1
1
package DGenericContainer .Map_HashMap ;
2
2
3
+ import java .util .ArrayList ;
3
4
import java .util .HashMap ;
5
+ import java .util .List ;
6
+ import java .util .Map ;
4
7
5
8
/**
6
9
* @author supremepole
@@ -17,5 +20,23 @@ public static void main(String[] args) {
17
20
hashMap .clear ();//删除所有的键值对
18
21
hashMap .entrySet ();//返回hashMap中所有映射项的集合视图
19
22
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 ());
20
41
}
21
42
}
You can’t perform that action at this time.
0 commit comments