Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: 0 error in Java

When i tried running this code I get this error..I dont know where i went wrong..

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
    at numericalComputatio.fibo.main(fibo.java:30)


package numericalComputatio;

public class fibo {     

    static double c = -0.618;
    // double c = [(1-sqrt(5))/2] = - 0.618 

    /**
     * Computes the fibonacci series
     * @param n
     * @return
     */
    private static double fibo(int n){

        if (n == 0)
           return 1;
        else if (n == 1)
            return c;
        else
        {
           double result = fibo(n - 1) + fibo(n - 2);
           return result;
        }
    }

    public static void main(String[] args) {
        int n = 0;
        double result = 0.0;
        double result1 = 1.000000000;
        if (args[0] != null)

Leave a Comment