title: ArrayIndexOutOfBoundsException - I dont understand why I am getting this error
body: <p>What is wrong with my code? I am trying to pass two arguments(one for random seed and another for the  and i get the array our of bounds exception error.. I dont understand what i am doing wrong.. I appreciate any help</p>
  
  <pre><code>import java.util.Random;
  
  public class sparse {
  
      public static int size;
      public static int matrix[][] = new int[size][size];
      public static int seed;
  
      public static void main(String args[]) {
  
          seed = Integer.parseInt(args[0]);
          size = Integer.parseInt(args[1]);
  
          matrix = matrixGen();
      }
  
      public static int[][] matrixGen() {
          Random r = new Random(seed);
          for (int i = 0; i &lt; matrix.length; i++) {
              for (int j = 0; j &lt; matrix[i].length; j++) {
                  matrix[i][j] = r.nextInt(100);
              }
          }
  
          for (int i = 0; i &lt; size; i++) {
              for (int j = 0; j &lt; size; j++) {
                  System.out.print(" " + matrix[i][j]);
              }
              System.out.println("  ");
          }
  
          return matrix;
      }
  }
  </code></pre>