编写一个类ExceptionTest,在main方法中使用try、catch、finally,要求:在try块中,编写被零除的代码。在catch块中,捕获被零除所产生的异常,并且打印异常信息在finally块中,打印一条语句。
package com.company;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
import java.util.Scanner;
import java.util.Vector;
public class Main {
/**
* @param args
* @lzx
*/
public static void main(String[] args) {
try {
int result = 10086 / 0;
}catch (RuntimeException e){
System.out.println("divide by zero error!");
}finally {
System.out.println("后面代码还能运行1");
}
System.out.println("后面代码还能运行2");
}
}