ConcurrentHashMap的key 是不能为空的

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/mottohlm/article/details/81046579
    ConcurrentHashMap 的key 是不能为空的,如果为空,那就会报“java.lang.NullPointerException”空指针异常。这是因为,该方法一进来就用入参hashCode方法去取hashCode ,根本没考虑入参为空的情况。

    而平时我们用的HashMap ,对入参为空是有处理的


猜你喜欢

转载自blog.csdn.net/mottohlm/article/details/81046579