DESKTOP-P665UA2_20200909-石家雨
问题
1、
public class NullHashMap {
public static void main(String[] args) {
Map<String , Integer> map = new HashMap<>();
map.put( null, null );
map.put( null , null );
map.put( " 牛肉面 " , null );
map.put( null , 50 );
System.out.println( map );
}
}
运行结果:{null=50, 牛肉面 =null}
说明HashMap里最多只能有一个键值对的key为空,但可以有无数多个的键值对的value为空。
吐槽
今天不知怎么过敏了,好痒
点赞