Your code is very difficult to read without nicely indented formatting. Please use code tags (use the "Code" button in the editor) in the future.
Your for loops have a stray semicolon after the parens that are causing behavior you do not expect (See the arrow below where I point out where the semicolon is in your for loops. Because of the semicolon, the code in the curly braces is not being executed as part of the for loop, instead it would be executed after the for loop.
for ( ... ) ; <--
Edit: Ack! I must have gone for a coffee break while I posted this, Amit posted an answer before mine posted.
Joined: May 20, 2011
Heh, forgot to add the part about the [code] tag. Thanks, Carol!
Why are you using 2 or 3 in the first place? You ought not to use number literals (except 0 1 and -1), but fields. In this case you should use thelengthfield of the array
Joined: Feb 26, 2012
Thank you guys! That's exactly what was happening the semicolons were killing my for loop. I took them out and there everything went. I was my first time posting so my apologizes for the sloppy code posting. I appreciate the assistance its exactly what I needed. Thanks again!
Joined: Oct 13, 2005
You would have been better to declare the counter variable as local to the loop. It doesn’t usually belong outside the loop, and in this case you would have suffered a compiler error.
subject: ArrayIndexOutOfBoundsException that I just can't figure out.