What ExceptionType should be used in Java to catch any exception that occurs in try block.
I just want to know that there is error in try block so that i can exit the program
try {
} catch (ExceptionType name) {
}
What ExceptionType should be used in Java to catch any exception that occurs in try block.
I just want to know that there is error in try block so that i can exit the program
try {
} catch (ExceptionType name) {
}
 
    
    You can use java.lang.Exception to catch most exceptions. Whether you should or not is debatable: perhaps a function higher up the call stack can deal with the exception more appropriately.
The true catch-all is java.lang.Thowable. But take care when intercepting that as doing so can interfere with the workings of the JVM.
 
    
    You can catch java.lang.Exception or java.lang.Throwable. Be aware, that it is anti-pattern to catch all Exceptions.
