示例
public
static
class
ThrowableSubclass
extends
Throwable {
public
ThrowableSubclass(
String
s ){
super(s);
}
}
public
class
Example {
public
void
run()
throws
ThrowableSubclass {
throw
new
ThrowableSubclass(
"Problem"
);
//$NON-NLS-1$
}
}
解决方案
扩展
java.lang.Exception
。
public
static
class
ExceptionSubclass
extends
Exception {
public
ExceptionSubclass(
String
s ){
super(s);
}
}
public
class
Example {
public
void
run()
throws
ExceptionSubclass {
throw
new
ExceptionSubclass(
"Problem"
);
//$NON-NLS-1$
}
}