Exception

package com.exception.demo02;

public class Test {
// 可能会存在异常的方法
static void test(int a) throws MyException{
System.out.println("传递的参数为:"+a);
if (a>10){
throw new MyException(a); //抛出
}
System.out.println("Ok");
}

public static void main(String[] args) {
    try {
        test(11);
    } catch (MyException e) {
      //  if(){    增加一些处理异常的代码
       // }
        System.out.println("MyException=>"+e);
    }
}

}

posted @ 2021-05-26 23:58  Big_chili  阅读(66)  评论(0)    收藏  举报