I have below classes.
public class ValidationException extends RuntimeException {
}
and
public class ValidationException
If you extend RuntimeException
, you don't need to declare it in the throws clause (i.e. it's an unchecked exception). If you extend Exception, you do (it's a checked exception).
Some people argue that all exceptions should extend from RuntimeException
, but if you want to force the user to handle the exception, you should extend Exception
instead.