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);
}
}
}
我在青春的田野里挥洒汗水和辛勤,希望在未来收获成熟与睿智

浙公网安备 33010602011771号