title: Filling a multidimensional array in Java using enhanced for loop
body: <p>I hope you all are doing well, so the problem I guess is in understanding the difference between those two codes:</p>
  
  <p>first code (filling multidim-array with enhanced for loop) - does not work</p>
  
  <pre><code>static char[][] battleBoard = new char[10][10];
  public static void main(String[] args)
  {
  
  
      for(char[] rows:battleBoard)
      {
          for(char column:rows)
          {
              column = '*';
          }
      }
  
  
  }
  </code></pre>
  
  <p>if we tried to print-out the array (expecting '*' to be assigned to each element in the array) using the following code - we fail (i.e it is still empty)!</p>
  
  <pre><code>for(int i=0;i&lt;battleBoard.length;i++)
      {
          for(int j=0; j&lt;battleBoard[i].length; j++)
          {
              System.out.print("|" + battleBoard[i][j] + "|");
          }
          System.out.println();
  
  
      }
  </code></pre>
  
  <p>But on the other hand we have(it works fine when printed):</p>
  
  <pre><code>static char[][] battleBoard = new char[10][10];
  public static void main(String[] args)
  {
  
  
      for(char[] rows:battleBoard)
      {
          Arrays.fill(rows, '*');
      }
  </code></pre>
  
  <p>So the question is: does not column, rows in the previous code-blocks stand for new variables - i.e <code>Arrays.fill(rows,'*')</code> shouldn't have met the need cause it fills ((rows char array)) but not ((battleBoard char array)) ; </p>
  
  <p>Thx in advance for helping me out!</p>