[jdom-interest] [Vote] NoSuchChildException
Alex Chaffee
guru at edamame.stinky.com
Thu Jul 13 04:12:50 PDT 2000
> Yes it is true. NoSuchElementException is thrown by the next() method
> of the Iterator interface, as well as by the nextElement() method of
> the Enumeration interface. For example from ListIterator:
OK, fine, if you're going to grep the source code... ;-)
You're right, the API is a bit schizophrenic. In fact, Iterator needs
to be committed to an institution and put on heavy medication. It's a
danger to itself and others. But List and Set and the other core
interfaces are pretty healthy.
LinkedList doesn't count since that's a concrete implementation class
that provides an extra method that's not in the List interface. In
fact, that exception is so flagrantly stupid and poorly placed that I
feel like sending a flame email to @author Josh Bloch right now. The
only reasoning I can come up with is that he really meant to throw
"IndexOutOfBoundsException"... Oh, wait, no, it only makes sense
because in this case (getFirst() and getLast()) "null" has a different
meaning. It means "the first item in the list is null", not "there is
no first item since the list is empty." I rest my case (as usual
among defense lawyers, providing three conflicting arguments).
- Alex, who didn't do it, and if he did, had a good reason, and if it
wasn't a good reason, then it was really someone else's fault
--
Alex Chaffee mailto:alex at jguru.com
jGuru - Java News and FAQs http://www.jguru.com/alex/
Creator of Gamelan http://www.gamelan.com/
Founder of Purple Technology http://www.purpletech.com/
Curator of Stinky Art Collective http://www.stinky.com/
More information about the jdom-interest
mailing list