?? testexception.java
字號:
public class TestException
{
public void test(int i) throws MyException
{
if(i>10)
{
MyException e = new MyException(i);
throw e;
}
}
public static void main(String []args)
{
try
{
TestException t = new TestException();
t.test(0);
t.test(10);
t.test(100);
}catch(MyException e){System.out.println(e.toString());}
}
/**
*@author liuzhongbing
*@param i 測試異常變量
*/
public class MyException extends Exception
{
int i;
public MyException(int t)
{
i = t;
}
public String toString()
{
return "拋出異常"+i;
}
}
};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -