The class itself that you want to use has already thrown an exception to an invalid input value.
While trying to create a method and conditional statement that checks with isblabla~() in advance,
I thought we could just wrap it up with a try.
You don't have to write dozens of lines of code.
However, this is not just an exception to the developer's mistakes
Sometimes the exception is to use it instead of a kind of conditional statement that works like part of logic.
I've seen some examples of this functional use, but I'm asking if it's the right thing to do.
Will there be no problem if I overuse it or should I avoid it?
exception
Exceptions should be used in exceptional situations and should not be used to control program flow. A well-designed API does not force clients to write exceptions when controlling program flows. There is a high possibility that JVM will not benefit from optimization. (Effective Java 2nd Item 57.)
© 2024 OneMinuteCode. All rights reserved.