• Post Reply Bookmark Topic Watch Topic
  • New Topic

ArrayOutOfBoundsException  RSS feed

 
Natasha Reaney
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

I'm working on an assignment (using Eclipse) and I keep getting an ArrayOutOfBoundsException. Can anyone help me figure out why and how to fix it?



Thank you!!!
 
Natasha Reaney
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nevermind! Got it working! Thanks anyway!
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well done!
Care to share the solution for the benefit of future users?
 
Suresh Sajja
Ranch Hand
Posts: 34
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Natasha Reaney wrote:



Can you check if each string array that you are referring from oneRow is of size at least 19?
Since you hard coded indexes while accessing string array, you have to be sure about your input.
 
Campbell Ritchie
Marshal
Posts: 55761
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suresh Sajja wrote: . . . Since you hard coded indexes while accessing string array, you have to be sure about your input.
Good point. Hard coding numbers like that is a hazardous practice. It is worth validating the input before you go near those array indices:-
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!