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.