I noticed that when you assign the array element, you're not checking the array bounds. I recommend checking that x is less than the length of your array before assigning a value to an array element with index x. That should fix your problem.
Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
Joined: Jul 30, 2003
In other words, instead of
I would use:
There are better ways to do this, but this solution at least checks the array bounds to make sure you don't exceed the array length. [ November 10, 2004: Message edited by: Jeff Bosch ]