title: Replacing values with for-loop in array in Java
body: <p>I'm trying to set the first and last row of an array to <code>1</code> in Java, but only the first element in the array gets changed. My code looks like this:</p>
  
  <pre><code>public void createArray(int height, int width){
  
          this.boardArray = new int [height][width];
  
          for (int i = 0; i &lt; height; ++i){
              for (int j = 0; i &lt; width; ++i){
                  if (i == 0 || i == height){
                      this.boardArray[i][j] = 1;
                  }
              }
          }
      }
  </code></pre>
  
  <p>But when I do this, I get this result:</p>
  
  <pre><code>1 0 0 0 0
  0 0 0 0 0
  0 0 0 0 0
  0 0 0 0 0
  0 0 0 0 0
  0 0 0 0 0
  0 0 0 0 0
  0 0 0 0 0
  0 0 0 0 0
  0 0 0 0 0
  </code></pre>
  
  <p>But I can't figure out why.</p>
  
  <p>Any suggestions on how to solve this would be appreciated, I'm new to Java so bear with me.</p>