amrigo
05-03-2007, 09:30 AM
Hi
I trying to run a fibonacci alghoritm but have an error in this line :
int n = Integer.parseint(args[0]); inside the main function.
Error message:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method parseint(String) is undefined for the type Integer
at Fib.main(fib.java:18)
How can i fix it ?
Thank´s in advance
import java.lang.Math;
public class Fib {
public static long fib(int n) {
if (n < 3)
return 1;
return fib(n-2)+fib(n-1);
}
public static void main(String [] args) {
int n = Integer.parseint(args[0]);
double result;
long time = System.currentTimeMillis();
result = fib(n);
time = System.currentTimeMillis()-time;
System.out.println("O número é: " + result);
System.out.println("Tempo: "+time);
}
}
I trying to run a fibonacci alghoritm but have an error in this line :
int n = Integer.parseint(args[0]); inside the main function.
Error message:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method parseint(String) is undefined for the type Integer
at Fib.main(fib.java:18)
How can i fix it ?
Thank´s in advance
import java.lang.Math;
public class Fib {
public static long fib(int n) {
if (n < 3)
return 1;
return fib(n-2)+fib(n-1);
}
public static void main(String [] args) {
int n = Integer.parseint(args[0]);
double result;
long time = System.currentTimeMillis();
result = fib(n);
time = System.currentTimeMillis()-time;
System.out.println("O número é: " + result);
System.out.println("Tempo: "+time);
}
}