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
Here:
args[0]
On line 30
if (args[0] != null)
You have to pass an argument.
args[0]
Tries to access the first element in the args array, since which is filled from the command line arguments. If you don't pass any arguments that array is empty and trying to access an non existing element in an array gives that exception.
You have to learn to read the exception stacktrace. They seem meaningless at first, but once you know how to read it, they are very helpful. Here's yours:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at numericalComputatio.fibo.main(fibo.java:30)
It reads like this:
public static void main
methodjava.lang.ArrayIndexOutOfBoundsException: 0
which means there there is an array involved and the index tried to be access as 0 ( the first element ) that gives you a good clue of what's going on.fibo.java:30
This is also very helpful specially when you have that source file at hand, and can look directly at that line number. I hope this helps.