【发布时间】:2016-04-22 05:19:02
【问题描述】:
为什么在HashSet中添加null不会抛出Exception,而是在TreeSet中添加null会抛出异常。
Set<String> s = new TreeSet<String>();
s.add(null);
抛出NullPointerException
Set<String> s = new HashSet<String>();
允许添加Null 值。
【问题讨论】: