Home > Back-end >  How to catch exceptions but immediately interrupt program?
How to catch exceptions but immediately interrupt program?

Time:01-10

As null pointer exception, can catch didn't catch that, if you don't catch one thousand met the null pointer is directly interrupt program,
The general exception can be like a null pointer exception, directly instead of capture interrupt? Sometimes catch word processing even, without processing program to continue to go on May have unexpected results,

CodePudding user response:

RuntimeException can not catch, error will be automatically thrown up, until the end did not catch the JVM abnormal quit
So your own exceptions should inherit from RuntimeException, otherwise you are defined in method throws exceptions, when a method is called must catch, unless a method is called method is defined as an exception is thrown
  • Related