Lecture 21
11
Exceptions in the Java API
•No throws cause needed for these, but you can catch them if you suspect one may be thrown
•NoSuchElementException
–thrown for you by JVM when you try to ask for a element after an Iterator is done
•NullPointerException
–thrown for you by JVM when you try to send a message to an Object that does not exist
•ClassCastException
–thrown for you by JVM when you try to cast an Object to a type it isn’t an instance of
•ArrayIndexOutOfBoundsException …
–