title: Index 2 out of bounds for length 2
body: <p>why it is giving error after 3rd input??</p>
  
  <pre><code>import java.util.Scanner;
  import java.util.Arrays;
  public class Baloon {
  
      public static void main(String[] args) {
  
          Scanner sc = new Scanner(System.in);
          int row = sc.nextInt();
          int col = sc.nextInt();
          int[][] arr  = new int[row][col];
          for(int i=0; i&lt;row; i++)
          {
              for(int j=0; i&lt;col; j++) { 
                  arr[i][j] = sc.nextInt();
              }
          }
      }
  
  }
  </code></pre>