Chapter 11 Cheatsheet
- throws: In class/ method declaration
- throw: Within a clause
- ✅
throw new RuntimeException(); - ❌
throw RuntimeException();
Exception tree
Checked exceptions
Checked exceptions extend
Exception, they MUST be declared or handled.
- IOException
- FileNotFoundException
- NotSerializableException
- ParseException
- SQLException
Unchecked exceptions
Unchecked exceptions extends
RuntimeException, they DON'T NEED to be declared or handled.
- ArithmeticException
- ArrayIndexOutOfBoundException
- ClassCastException
- NullPointerException
- IllegalArgumentException
- NumberFormatException
Error class
- StackOverflowError
- ExceptionInInitializerError
- NoClassDefFoundError
Super exceptions & sub exceptions
- IOException (super) -> FileNotFoundException (sub)
- IllegalArgumentException (super) -> NumberFormatException (sub)