Take a look at javadoc for Collection # add
Many exceptions were mentioned there:
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.
If you have patience, I would recommend carefully documenting the possible exceptions thrown by your methods in this way. In a sense, this is even more important for excluded exceptions, since checked exceptions are somewhat self-documenting (the compiler forces the calling code to recognize them).
Sam Barnum May 05 '09 at 11:28 a.m. 2009-05-05 11:28
source share