你可以尝试着注释掉throws或throw这一句看一下.就明白了!
class SimpleException extends Exception{}
public class SimpleExceptionDemo{
public void f() throws SimpleException{
System.out.println("Throw SimpleException from f()");
throw new SimpleException();
}
public static void main(String[] args){
SimpleExceptionDemo sed = new SimpleExceptionDemo();
try{
sed.f();
} catch(SimpleException e){
System.err.println("Caught it!");
}
}
}