[Solved] Java – Error in Enhanced for loop


a_row is containing all the rows of the two dimensional array and you are
accessing a_row[i] where i value of the row and you have no a_row[3]
in your code change like following

 for(int[] a_row: a){
    for(int index=0; index < a_row.length; index++){
        a_row[index]+=1;
    }
}

for(int[] a_row: a){
    for(int i: a_row){
        System.out.print(i+"\t");
    }
    System.out.println("\n");
}

3

solved Java – Error in Enhanced for loop