File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes ArrayIndexOutOfBounds Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ArrayIndexOutOfBounds" Watch "ArrayIndexOutOfBounds" New topic


RJ Cavender
Ranch Hand

Joined: Jul 26, 2006
Posts: 51
Hello, this is one of those "it SHOULD work" things. Im getting an ArrayOutOfBounds error and not being too familar with it, I thought someone might be able to help point me to the trouble maker. It seems to refer to line #582 and #32. Anybody been through this type of error?

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
this looks suspicious

if 'count' represents the size of the array, the loop should be
for(i=0; i<count; ++i)// '=' removed
Hyndavi Padamata

Joined: Apr 19, 2007
Posts: 12

I think What Dunn suggested is right.

Because if count represents size of the array, array index will starts from zero and ends with n-1 (where n is the length of the array). So with the condition the loop will iterate through nth element also. So there is a chance to get ArrayIndexOutOfBounds Exception.
RJ Cavender
Ranch Hand

Joined: Jul 26, 2006
Posts: 51
Thank you very much. That helped.
I agree. Here's the link:
subject: ArrayIndexOutOfBounds
It's not a secret anymore!