为 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" );
} catch ( ClassNotFoundException e2 ) {
System.out.println( "No class " + e2.getMessage() );
}
}
|
|