Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ArrayIndexOutOfBounds

 
RJ Cavender
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this looks suspicious


if 'count' represents the size of the array, the loop should be
for(i=0; i<count; ++i)// '=' removed
 
Hyndavi Padamata
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much. That helped.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic