public class MyException extends Exception
...{
MyException(String str)
...{
super(str);
}
}
public class MyTest
...{
public void f()throws MyException
...{
throw new MyException("f() exception");
}
}
public class Main
...{
public static void main(String[]args)
...{
try
...{
new MyTest().f();
}catch(MyException me)
...{
System.out.println(me);
}finally
...{System.out.println("finally");
}
}
}
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/