Custom Exceptions in Java — a practical guide to Java custom exception with clear examples you can reuse in real projects.
Java Tutorial Series (49/90). Prefer one article? Read the complete Java tutorial.
Short description
Extend `Exception` (checked) or `RuntimeException` (unchecked) based on API needs.
Custom exception
class InsufficientFunds extends RuntimeException {
InsufficientFunds(String msg) { super(msg); }
}