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 Help with an array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help with an array" Watch "Help with an array" New topic

Help with an array

Brent Lancelot

Joined: Apr 01, 2006
Posts: 8
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

Joined: Aug 31, 2004
Posts: 11343

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}, ...

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
Arun Maalik
Ranch Hand

Joined: Oct 25, 2005
Posts: 216
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.
subject: Help with an array