用户定义的exception是已检查或未检查的exception

在我的Web应用程序中创建了一个用户定义的exception,它扩展了Exception.Is it Checked或unchecked exception

public class InvalidDataException extends Exception{ public InvalidDataException() { super(); // TODO Auto-generated constructor stub } /** * @param arg0 */ public InvalidDataException(String message) { super(message); // TODO Auto-generated constructor stub } } 

只有那些属于RuntimeException子类的exceptionRuntimeException视为未选中

你的不是,因此是一个经过检查的例外。

这是一个经过检查的exception类。 任何扩展Exception类的类都将是用户定义的Checkedexception类。 任何扩展RuntimeException的类都将是Uncheckedexception类。

您可以使用IllegalArgumentException 。

此exception未经检查,而您的exception被检查为@duffymo&@ aix评论。

用户定义的exception是经过检查的exception,因为它们是使用Exception类扩展的,Exception类是发生的所有exception的超类,其中未经检查的exception通过运行时exception进行扩展。

这两个类被称为部分检查exception。

1.)exception类

2.)可抛出的课程

它调用部分检查,因为它们的某些子类是未选中的。 所以你扩展了Exception类,然后它是Checkedexception