M
Murat Tasan
in a Set (and other Collection sub-interfaces), there are some rather
silly declarations for the jdk API.
for example, the Set.contains(Object) method throws NullPointerException
if, "the specified element is null and this set does not support null
elements (optional)."
while i understand why this is optional, it makes headaches for a
definition like this for a method like contains(). if anyone is accepting
a general Set into a custom method then, and i try to search for a null
element, i now have to worry about catching an exception.
such a declaration certainly makes sense for modification methods (like
add()), but does anyone know what the rationale is for this design in
non-modification methods (like contains())?
thanks for any insight,
murat
silly declarations for the jdk API.
for example, the Set.contains(Object) method throws NullPointerException
if, "the specified element is null and this set does not support null
elements (optional)."
while i understand why this is optional, it makes headaches for a
definition like this for a method like contains(). if anyone is accepting
a general Set into a custom method then, and i try to search for a null
element, i now have to worry about catching an exception.
such a declaration certainly makes sense for modification methods (like
add()), but does anyone know what the rationale is for this design in
non-modification methods (like contains())?
thanks for any insight,
murat