title: Convert 1d array to 2d array in JAVA
body: <p>I am trying to input values from a 1d array into a 2d array in java.</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>int[] input2 = {
      0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0
  };
  int[][] arr = new arr[3][4];
  
  for (int i = 0; i &lt; arr.length; i++) {
      for (int j = 0; j &lt; arr[i].length; j++) {
          System.out.println("index" + ((i * arr.length) + j));
          arr[i][j] = input2[(i * arr.length) + j];
          //System.out.print("  " + arr[i][j]);
  
      }
      //System.out.println();
   }
  </code></pre>
  
  <p>But what it outputs is:</p>
  
  <pre><code>index0
  index1
  index2
  index3
  index3
  index4
  index5
  index6
  index6
  index7
  index8
  index9
  </code></pre>
  
  <p>which means that I am getting the indexes wrong from 1d array.
  Where did I go wrong ?</p>