範例

public static class ClassA throws NullPointerException {
public void methodA {

throw new NullPointerException();
}

解決方案
針對 throws 子句中所宣告的每個異常狀況,各建立一個專用的 catch 子句。

public static class ClassA throws Error {
public void methodA {

throw new Error();
}