?? ex070201.java
字號(hào):
class Factorial{
static long method(int n) throws ArgumentException{
long s=1;
if (n>=0){
if (n>=0){
for(int i=2;i<=n;i++){
s=s*i;
}
}
}else{
throw new ArgumentException(n);
}
return s;
}
public static void main(String[] args){
try{
System.out.println("n! = " +method(-1));
}catch (ArgumentException e){
System.out.println(e);
}
}
}
class ArgumentException extends Exception{
private int n;
ArgumentException(){
}
ArgumentException(int n){
this.n=n;
}
public String toString(){
return ("Exception["+n+"]");
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -