关于java Fibonacci的问题!!!
代码如下public class Fibonacci{
public static void main(String args[]){
int n = Integer.parseInt(args[0]);
int n1 = 1;//第一个数
int n2 = 1;//第二个数
int sum = 0;//和
if(n<=0){
System.out.println("参数错误!");
return;
}
if(n<=2){
sum = 1;
}else{
for(int i=3;i<=n;i++){
sum = n1+n2;
n1 = n2;
n2 = sum;
}
}
System.out.println(sum);
}
}
运行后显示Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at com.liushiqi.Fibonacci.main(Fibonacci.java:5) 这是怎么回事呢??