Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with an array

 
Brent Lancelot
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi i need some help with an array it says Hit uncaught exception java.lang.ArrayIndexOutOfBoundsException but im sure the index is ok

package Chapter5;



the second for loop is for organizing them


EDIT by mw: Added Code Tags to original poster's indentation.
[ April 01, 2006: Message edited by: marc weber ]
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

The second nested array (hours[1]) only has 6 elements...

int [][] hours = { {2,4,3,4,5,8,8}, {7,3,4,3,4,4}, ...
 
Arun Maalik
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey sir U r doing mistake to index of array. Like U have decleared 6 elements in second row of hours array. Count correctly isn't it. so y (in the inner loop) maximum should be up to 5. But U have set y as 6 that's why it is throwing such exception. Eithe change y up to 5 or increse 1 element in second row of hours array.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic