Java errors and exceptions
Explore common Java exceptions through failed bookings, partial files, and cancelled jobs. Checked exceptions must be caught or declared. RuntimeException and its subclasses are unchecked.
Input and validation
- NumberFormatExceptionRecover from a mistyped ticket quantity
- IllegalArgumentExceptionReject a booking for zero people
- ClassCastExceptionCheck the type of an imported fare
- DateTimeParseExceptionCheck a delivery date entered on a form
- NullPointerExceptionPrint a label when the phone number is missing
- PatternSyntaxExceptionValidate a saved product search
- StringIndexOutOfBoundsExceptionRead the depot prefix on a damaged label
State and collections
- ArithmeticExceptionSplit an equipment fee across a class
- ConcurrentModificationExceptionRemove an expired pass during inspection
- IllegalStateExceptionAdd an item after checkout closes
- IndexOutOfBoundsExceptionFind a seat after the coach changes
- NoSuchElementExceptionCall the next person at the clinic
- UnsupportedOperationExceptionAdd a stop to a published bus route
Files and streams
- NoSuchFileException and IOExceptionHandle a receipt that has not been saved
- Try-with-resourcesClose a reader after checking a delivery list
- EOFExceptionRead a stock count from a short record
- FileAlreadyExistsExceptionSave a report without replacing the first copy
- FileNotFoundExceptionOpen the first receipt of the day
- IOExceptionRead from a finished receipt import
Jobs and runtime
- CancellationExceptionCollect a cancelled print job
- ClassNotFoundExceptionLoad an optional invoice exporter
- ExecutionExceptionFind the reason a background import failed
- InterruptedExceptionStop waiting when a shift ends
- TimeoutExceptionLimit the wait for a shipping quote