?? testexception.java
字號:
class MyException extends Exception
{
int r;
public MyException(String msg,int r)
{
super(msg);
this.r=r;
}
public int getR()
{
return r;
}
}
class Test
{ int r;
public double area(int r)throws ArithmeticException,MyException
{
this.r=r;
if(r<0)
throw new MyException("半徑為負數了",r);
double result=3.14*r*r;;
return result;
}
}
public class TestException
{
public static void main(String args[])
{
try{double result=new Test().area(-3);
System.out.println("the result is"+result);
}
catch(MyException e1){
System.out.println("is MyException");
System.out.println(e1.getMessage());
System.out.println("the R is "+e1.getR());
}
finally{
System.out.println("program is running into finally");
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -