5.11JAVA课堂记录复习1:
package Demo01;
public class A {
public static void main(String[] args) {
String test ="yes";
try {
System.out.println("start try");
doRisky(test);
System.out.println("end try");
} catch (Exception e) {
System.out.println("Scary exception");
}finally{
System.out.println("finally");
}
System.out.println("end of main");
}
static void doRisky(String test)throws ScaryException{
System.out.println("start risky");
if("yes".equals(test)) {
throw new ScaryException();
}
System.out.println("end risky");
return;
}
}
package Demo01;
public class ScaryException extends Exception {
}
运行结果如图: