Exception is runtime errors.
<aside> 💡
Try to handle exception, let the program continue. Else, app might crashed / bringing bad UX.
</aside>
Custom Exception
class InterviewBit {
public static void main(String args[]) throws CustomException {
// Throwing the custom exception be passing the message
throw new CustomException(" This is my custom Exception ");
}
//Creating Custom Exception Class
class CustomException extends Exception{
//Defining Constructor to throw exception message
public CustomException(String message){
super(message);
}
}
throw
throw