title: My "for loops" won't actually loop but it's not throwing any codes and I don't see a problem
body: <p>All of this is just for reference so you can see what's going on if you need to look. I'm creating a grid game with required fields and methods. Some of which I've added to the assignment for ease of use:</p>
  <p>char[][] checkGameBoard</p>
  <p>boxTop()</p>
  <p>boxBottom()</p>
  <p>printSubRows()</p>
  <pre><code>import java.util.Scanner;
  import java.util.Random;
  
  public class SweeperGame {
      private char[][] gameBoard;     // Represents the grid. [Rows][Columns]
                                      // For accessing, two nested for loops are needed that will sort, add, and track
      private char[][] checkGameBoard;
  
      private int treasureX;
      private int treasureY;
      private int totalMoves;
      private boolean found;
  
      public static void main(String[] args) {        // Driver File
          Scanner s = new Scanner(System.in);
          int height;
          int width;
          boolean done = false;
          int x;
          int y;
  
          do {
              System.out.println(&quot;Sweep the sand and find the treasure&quot;);
              System.out.println(&quot;Please enter the number of height and width&quot;
                      + &quot;\nof the game board&quot;);
              System.out.print(&quot;Height of board: &quot;);
              height = s.nextInt();
              System.out.print(&quot;Width of board: &quot;);
              width = s.nextInt();
              SweeperGame game = new SweeperGame(height, width);
              s.nextLine();
              do {
                  do {
                      System.out.print(&quot;Enter treasure coordinates separated by a space: &quot;);
                      x = s.nextInt();
                      y = s.nextInt();
                  } while (!game.checkOutOfBounds(x, y) || game.beenSwept(x, y));
                  done = game.digSand(x, y);
                  System.out.println(game.toString());
                  s.nextLine();
              } while (!done);
              System.out.println(&quot;You found the treasure in &quot; + game.getTotalMoves() + &quot; moves!&quot;);
              System.out.println(&quot;Out of &quot; + game.getBoardHeight() * game.getBoardWidth() + &quot; possible moves.&quot;);
              System.out.print(&quot;Would you like to find more treasure [Y/N]? &quot;);
          } while (s.nextLine().equalsIgnoreCase(&quot;Y&quot;));
  
      }
  
      public SweeperGame(int height, int width) {
          /*
          Receives two int parameters as the user's input for height and width of grid where treasure is buried
          instantiates the gameBoard array [x][y]
          Initialize gameBoard cells to contain a space ''. Done with single quotes only. (Why does the single quotes matter?)
          Set treasureX/treasureY randomly using the first/second parameter, respectively
          Set gameBoard[treasureX][treasureY] to 'T'
          Set total moves to 0
          Set found to false
           */
  
          totalMoves=0;
          found = false;
  
          // Build grid
          if (height == 0 &amp;&amp; width == 0) {
              throw new IllegalArgumentException();
          }
  
          // Instantiates gameBoard
          gameBoard = new char[height][width];
          checkGameBoard = gameBoard;                 // Might have to move this to after set treasure. We'll see how it plays out
  
          // Initialize gameBoard's cells
          for (int i=0; i&lt;height; i++){
              for (int j=0; j&lt;width; j++){
                  gameBoard[i][j] = ' ';
              }
          }
          System.out.println(&quot;X is :&quot; + gameBoard.length + &quot;. Y is :&quot; + gameBoard[1].length + &quot;.&quot;);
  
          // Set treasureX
          Random randomX = new Random(width);
          treasureX = randomX.nextInt(width);
  
          // Set treasureY
          Random randomY = new Random(height);
          treasureY = randomY.nextInt(height);
  
          // Setting the treasure 'T' into the gameBoard
          gameBoard[treasureX][treasureY] = 'T';
  
      }
  
      public boolean beenSwept(int x, int y){         // Receives x &amp; y and returns true if space has already been searched
          // Reversed because of dimensions
          if (checkGameBoard[x][y] == 'x'){
              return true;
          }
          else{
              checkGameBoard[y][x] = 'x';
              return false;
          }
      }
  
      public boolean treasureFound(int x, int y){     // Receives x &amp; y and returns true if treasure is at given locations
          if (this.treasureX == x &amp;&amp; this.treasureY == y){
              return true;
          }
          else{
              return false;
          }
      }
      public boolean checkOutOfBounds(int x, int y){                      // Receives x &amp; y and returns true if within array (gameBoard), false if not
          int h = gameBoard[1].length;    // X value of gameBoard
          int v = gameBoard.length;       // Y value of gameBoard
          if ((x &gt; 0 &amp;&amp; x &lt;= h) &amp;&amp; (y &gt; 0 &amp;&amp; y &lt;= v)){
              return true;
          }
          else{
              return false;
          }
      }
      public int getBoardHeight(){                                        // Returns the height of the board
          return gameBoard.length;
      }
      public int getBoardWidth(){                                         // Returns the width of the board
          return gameBoard[1].length;
      }
      public int getTotalMoves(){                                         // Returns the total amount of moves taken
          return totalMoves;
      }
  
      public boolean digSand(int x, int y){           // Receives x &amp; y and returns true if the treasure if found, false otherwise.
          if (x == treasureX &amp;&amp; y == treasureY){      // Also displays &quot;Manhattan distance&quot; to treasure. Increment number of moves taken if the treasure isn't found and space hasn't been searched already
              found = true;
              return true;
          }
          else {
              //if (beenSwept = true, add one to totalMoves)
              if (beenSwept(x,y)==true){
                  totalMoves = totalMoves + 1;
              }
              return false;
          }
      }
  </code></pre>
  <p>This is the part that needs attention. My for-loops don't throw any codes but won't loop either. The output is just a singular line with some spaces which is just the part before &quot;checkGameBoard[i][j]&quot;
  I'm trying to get the for-loop to cycle so that I can create the output that's commented out (at the very bottom)</p>
  <pre><code>    public String toString(){                       // Displays the current gameBoard array and it's contents except for the location of the treasure
  
          int rows = gameBoard.length;
          int columns = gameBoard[1].length;
  
          for (int i = 0; i &lt;= rows; i++) {
              boxTop();
              printSubRows();                                 // Prints top and the sub-rows
              for (int j = 0; j &lt; columns; j++) {                 // Columns of gameBoard
                  return &quot;|   &quot; + checkGameBoard[i][j] + &quot;   &quot;;
              }
              printSubRows();
              return null;
          }
          boxBottom();
          return null;
          /*
          Prints the following:
          |       |       |       |       |
          |       |       |       |       |
          |       |       |       |       |
          |   x   |   x   |   x   |   x   |
          |       |       |       |       |
          |       |       |       |       |
          |       |       |       |       |
           */
      }
  
      public String boxTop(){
          return (&quot;--------&quot;.repeat(gameBoard.length)+&quot;\n&quot;);
      }
      public String boxBottom(){
          return &quot;--------&quot;.repeat(gameBoard.length);
      }
      public String printSubRows(){
          String filler = (&quot;|       &quot;).repeat(gameBoard[1].length) + &quot;\n&quot;;
          return (filler.repeat(3));    // 3 is the number of sub-rows before a character input is required for the grid.
      }
  
  }
  </code></pre>