Try & Catch => By Developer
try {
statement;
} catch (ExceptionName var) {
var.printStackTrace();
var.getMessage();
} finally {
// Used to release Extra resources
}
User Defined => You as a designer would like to throw exception to instruct the developer to handle if really wants, Stops the program
// App.java
public static int functionName() throws InputException {
if (condition) throw new ExceptionName("")
else statement;
}
// ExceptionName.java
public class ExceptionName extends Exception {
public ExceptionName(String msg) {
super(msg);
}
}