I am a beginner and using Java arrays for the first time. When I output my code I get this error. There is no errors in my actual code, so I do not see where the problem is in my code.
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at sumdouble.Sumdouble.main(Sumdouble.java:24)
Here is my code
package sumdouble;
public class Sumdouble {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
double sum = 0;
int number = 1;
double array[] = new double [5];
for (number = 0; number < 5; number++)
{
array[number] = Double.parseDouble(args[number]);
System.out.println("The" +number+ "argument value is: " +array[number]);
for(double numb: array)
{
sum = sum + numb;
}
}System.out.printf("Sum of all numbers = %2f", sum);
// TODO code application logic here
}
}