?? 例4-9.java
字號:
//例4.9
public class tt
{
static double sqrt(double i) throws IllegalArgumentException
{
if(i<0)
{
IllegalArgumentException e=new IllegalArgumentException("不能求負(fù)數(shù)的平方根");
throw e;
}
return(Math.sqrt(i));
}
public static void main(String args[])
{
System.out.println("IllegalArgumentException example");
try
{
System.out.println(sqrt(4));
}
catch(IllegalArgumentException e)
{ System.out.println("\t捕獲異常:"+e); }
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -