/*what should we do in the catch block?
* first, we need to print the stack trace by using e.printStackTrace();
* second, we need to print out the runtime variables to help us determine what caused this exception
* third, this is not must, but you need to ask yourself a question, do you need to terminate the program when the exception happens?
*/
package c1;
public class Test{
public static void main(String[] args){
try{throw new Exception();
}
catch(Exception e){
e.printStackTrace();
System.out.println(args);// print out the runtime variables
System.exit(0); //terminate the program or Runtime.getRuntime().exit(0);
}
}
}
阅读(422) | 评论(0) | 转发(0) |