Styrow.dev
Question 212 of 247
Java Topic: General medium

How to create custom exceptions?

Question

How to create custom exceptions?

Answer

By extending the Exception class or one of its subclasses. Example:

class MyException extends Exception { public MyException() { super(); } public MyException(String s) { super(s); } }