index out of range error in java : <p>I am trying to find the max value of a 2D array in java.</p>

<pre><code> import java.util.*;

 public class ikiBoyutlu {

 public static void ikiBoyut(int[][]a){
    int eb= a[0][0];

    for(int i=0;i&lt;a.length;i++){
        for(int j=0; j&lt;(a[0].length);j++){
            if(a[i][j]&gt;eb){
                eb=a[i][j];
            }

        }

    }
    System.out.println("The max value of array= "+ eb);
}

public static void main(String[] args){

    int a[][] ={{2,5,7,0,-6,28,43},{-96,45,3,21}};
    ikiBoyut(a);

}

}
</code></pre>

<p>But I get index out of range error. I wonder why?</p>

<p>Thanks!</p>
