Why adding null
in HashSet
does not throw Exception
,but adding null
in TreeSet
throw Exception.
Set<String> s = new TreeSet<String>();
s.add(null);
throws NullPointerException
Set<String> s = new HashSet<String>();
Allow Null
value to be added.