示例

public static class Loader {
public void load() throws UnsupportedOperationException, ClassNotFoundException {}
}


public static void main(String[] args) {
Loader loader = new Loader();
try {
loader.load();
} catch ( Exception e ) {
e.printStackTrace();
}
}

解决方案
为 throws 子句中声明的每个异常创建专门的 catch 子句。

public static class Loader {
public void load() throws UnsupportedOperationException, ClassNotFoundException {}
}


public static void main(String[] args) {
Loader loader = new Loader();
try {
loader.load();
} catch ( UnsupportedOperationException e1 ) {
System.out.println( "load is not implemented" ); //$NON-NLS-1$
} catch ( ClassNotFoundException e2 ) {
System.out.println( "No class " + e2.getMessage() ); //$NON-NLS-1$
}
}