程序1:public class Fab{
public static void main(String[] args){
System.out.println(f(40));
}
public static long f(int index){

if(index == 1||index == 2 ){
return 1;
}

long f1 = 1l;
long f2 = 2l;
long f = 0;

for(int i=0;i<index-2;i++){
f =f1 + f2;
f1 = f2;
f2 = f;

}
return f;
}
}
运行结果为165580141程序2:
public class Fab {
public static void main(String[] args) {
System.out.println(f(40));
}

public static long f(int index) {
if(index < 1) {
System.out.println("invalid parameter!");
return -1;
}

if(index == 1 || index == 2) {
return 1;
}

long f1 = 1L;
long f2 = 1L;
long f = 0;

for(int i=0; i<index-2; i++) {
f = f1 + f2;
f1 = f2;
f2 = f;

}

return f;
}
}运行结果为102334155这两程序都是在DOS环境编译运行?跪求高手讲下为什么?