当前位置: 移动技术网 > IT编程>开发语言>Java > ConcurrentHashMap不支持null

ConcurrentHashMap不支持null

2020年04月30日  | 移动技术网IT编程  | 我要评论
    @override
    public void run(string... args) throws exception {
        concurrenthashmap<string, string> concurrenthashmap = new concurrenthashmap<>();
        concurrenthashmap.put(null, "1");//npe
        concurrenthashmap.put("1", null);//npe
        concurrenthashmap.get(null);//npe
        hashmap<string, string> hashmap = new hashmap<>();
        hashmap.put(null, "1");//ok
        hashmap.put("1", null);//ok
        system.out.println(hashmap.get(null));//"1"
        system.out.println(hashmap.get("1"));//null
    }

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网