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
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
Exceptions will be thrown up one level at a time, with no return value.
One method’s exit is return, and the other is to throw an exception. When an exception is thrown, there is no return value
throw new RuntimeException(msg);
Use try catch to catch exceptions
e.getMessage();
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
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