exceptioninherit2.java
来自「Corejava」· Java 代码 · 共 43 行
JAVA
43 行
//ExceptionInherit2.java
class MyException2 extends Exception
{
private int i;
public MyException2()
{
}
public MyException2(String message)
{
super(message);
}
public MyException2(String message, int x)
{
super(message);
i = x;
}
public int value()
{
return i;
}
}
public class ExceptionInherit2
{
public static void f() throws MyException2
{
System.out.println("Throwing MyException2");
throw new MyException2("the third constructor!!!", 4);
}
public static void main(String[] args)
{
try
{
f();
}
catch(MyException2 e)
{
System.out.println("e.value()=" + e.value());
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?