The error message also tells you the exact line where the error occurred. That would be very useful to know.
But in the meantime you create an array numbers with exactly one element (length 1), then make lots of uses of it which seem to imply that it's longer than that?
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
@ajaxx195
Actually the code sets the size of array to 1.
double[] numbers = {0}; // means numbers is now [0]
The problem is that using array with [] is a static size array. The array size cannot be changed during the program unless you redeclare it... In other words, once it passes the first element, it will go out of bound...
Taywin
Posting Virtuoso
1,727 posts since Apr 2010
Reputation Points: 229
Solved Threads: 239
Watch your array (number).You haven't set the size of array.
Do you mean numbers? if so double[] numbers = {0};
declares and initialises it to one element (value 0.0) - so the size is 1.
snap!
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073