Take a look at the javadoc for java.util.Collection#add
http://download.oracle.com/javase/1.5.0/docs/api/java/util/Collection.html#add(E)
There's a whole slew of unchecked exceptions mentioned:
Throws:
UnsupportedOperationException - add is not supported by this collection.
ClassCastException - class of the specified element prevents it from being added to this collection.
NullPointerException - if the specified element is null and this collection does not support null elements.
IllegalArgumentException - some aspect of this element prevents it from being added to this collection.
It is recommend thoroughly documenting the possible exceptions thrown by your methods this way. In a way, it's even more important to do this for unchecked exceptions, as checked exceptions are somewhat self-documenting (the compiler forces the calling code to acknowledge them).
Good doc sir.. keep it on...
ReplyDeleteThank you Sir :)
Delete