title: Make a square shape of asterisc around border of 2D Array
body: <p>I am trying to fill with asterisks only the outside border of a 2D Array I have half of it done, but it seems that I cant get it to fill the last column and the last row in the 2D array.</p>
  
  <p><a href="https://i.stack.imgur.com/btTnn.png" rel="nofollow noreferrer">so far I can do this</a></p>
  
  <p>and here is my code:</p>
  
  <pre><code>for (int i = 0; i &lt; array.length; i++) 
  {
      for (int j = 0; j &lt; array.length; j++) 
      {
          if (array[i][j] == array[0][j] || array[i][j] == array[i][0])
          {
              array[i][j] = "*";
          }
      }
  }
  </code></pre>
  
  <p>but obviously I want to finish the Square shape around the 2D array, so I tried something like this.</p>
  
  <pre><code>for (int i = 0; i &lt; array.length; i++) 
  {
      for (int j = 0; j &lt; array.length; j++) 
      {
          if (array[i][j] == array[array.length - 1][j]
                      || array[i][j] == array[i][array.length - 1]) 
          { 
              array[i][j] = "*";
          }
      }
  }
  </code></pre>
  
  <p>My idea was just to go to the last valid position in the 2D array and simply print the column and the row but it doesn't seem to work. Thanks to all the help I can get, I really appreciate it as I'm a learner in Java.</p>