关于TreeSet和HashSet的addAll报错
使用TreeSet的addAll() 一个不为空的list集合结果报空指针,而使用HashSet却没有报错;
原因在于TreeSet底层是TreeMap,TreeMap的key不能为null
而HashSet的底层是HashMap,HashMap的key可以为null
关于TreeSet和HashSet的addAll报错
使用TreeSet的addAll() 一个不为空的list集合结果报空指针,而使用HashSet却没有报错;
原因在于TreeSet底层是TreeMap,TreeMap的key不能为null
而HashSet的底层是HashMap,HashMap的key可以为null