Except for poor readability, there is no problem. A method may return different resultsaccording to different situations, but each call will only return one of the results.
A better way to write is to prioritize exception branches in the method body and return the exception result as early as possible.
One key point is that a method will only return once when called. If your method may return twice, it will not pass compilation. Because the method returns a value, it means that the method has reached the end point and the program will exit the method.
If you are pursuing readability, write like this:
Except for poor readability, there is no problem. A method may return different resultsaccording to different situations, but each call will only return one of the results.
A better way to write is to prioritize exception branches in the method body and return the exception result as early as possible.
The answer above is more optimized
One key point is that a method will only return once when called. If your method may return twice, it will not pass compilation. Because the method returns a value, it means that the method has reached the end point and the program will exit the method.
I think it should be like this