myexception.java
来自「苏州大学java学习的ppt课件」· Java 代码 · 共 34 行
JAVA
34 行
class UserException extends java.lang.Exception
{
UserException(){
super();
System.err.println("User defined error");
}
UserException(String s){
super(s);
System.err.println("User defined error"+s);
}
};
class TestException
{
public TestException(){ System.out.println("User init");};
public void test() throws UserException{
throw new UserException();
}
};
public class MyException
{
public static void main(String[] args)
{
System.out.println("Hello World!");
try{
TestException te = new TestException();
te.test();
}catch(Exception e){ System.err.println("catched");};
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?