java中有返回值的函数中throw new exception会给函数返回值吗?返回值是什么?
PHPz2017-04-18 10:52:00
One method’s exit is return, and the other is to throw an exception. When an exception is thrown, there is no return value
迷茫2017-04-18 10:52:00
throw new RuntimeException(msg);
Use try catch to catch exceptions
e.getMessage();
ringa_lee2017-04-18 10:52:00
Throw an exception. The code that calls this method will either catch the exception or continue to throw the exception to the upper caller. There is no chance for you to receive the return value
ringa_lee2017-04-18 10:52:00
It depends on the situation. Runtime exceptions will not cause the program to interrupt, and will continue to execute, then there will be a return value. Non-runtime exceptions will directly interrupt the program, so there is no return value. If you respond to exceptions It doesn’t exist if it’s not captured