File tree Expand file tree Collapse file tree
src/DGenericContainer/Map_HashMap Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package DGenericContainer .Map_HashMap ;
2+
3+ import java .util .Collections ;
4+ import java .util .HashMap ;
5+ import java .util .Map ;
6+
7+ /**
8+ * @ClassName MapHashMap
9+ * @Description
10+ * @Date 2022/9/20 11:39
11+ * @Version 1.0.0
12+ **/
13+ public class MapHashMap {
14+ public static void main (String [] args ) {
15+ HashMap <String , String > hashMap =new HashMap <>();
16+ //错误示例:Collections.emptyMap()的返回类型为Map
17+ //HashMap<String, String> hashMap1=Collections.emptyMap();
18+ useHashMap (hashMap );
19+ Map <String , String > map =new HashMap <>();
20+ //错误示例:方法参数为hashMap类型
21+ //useHashMap(map);
22+ Map <String , String > map1 = Collections .emptyMap ();
23+ //错误示例:方法参数为hashMap类型
24+ //useHashMap(map1);
25+ }
26+
27+ public static void useHashMap (HashMap <String , String > hashMap ){
28+
29+ }
30+ }
You can’t perform that action at this time.
0 commit comments