An ArrayIndexOutOfBoundsException happens when you try to access an element in an array using an index that is outside the range the array contains. For example an array defined like this:
has a range 0 to 2 inclusive. If I write:
I will get an ArrayIndexOutOfboundsException
Why is htis happening to your code? Well, you logic is wrong. You need to split the String to get your array of parts, then step through that array adding the parts. What you have written steps through the String one character at a time, then split the String repeatedly.
The steps should be in this order:
Split the String "source" into an array of parts
loop through the array of parts
for each part parse its value and add to a result.
If you look at your code you should be able to see what needs changed to get this to work. [ May 22, 2006: Message edited by: Paul Sturrock ]