- public class Test {
- public static void main(String[] args) {
- int a = 5;
- int b = 0;
- int c;
- try {
- System.out.println("异常发生之前");
- c = a/b;
- System.out.println("异常发生之后");
- } catch (Exception e) {
- System.out.println("catch块代码");// TODO: handle exception
- }finally{
- System.out.println("这是Finally块");
- return ;
- }
- }
- }
复制代码
结果是
异常发生之前
catch块代码
这是Finally块
|