Java Reference
In-Depth Information
•
Methods that return individual elements of a collection will give
you a
NoSuchElementException
if the collection is empty.
•
Methods or constructors that take parameters of reference type
usually throw
NullPointerException
if passed a
null
reference. The
exceptions to this are collections that accept
null
elements, with
which
null
can be used when adding, removing, or searching.
Any variations to the above, or other exceptions generated, are docu-
mented on a case-by-case basis.