title: 2d array gamemap line numbering
body: <p>I'm trying to create a 2d gamefield with line numbering, but I can't get my head around how to code the numbering correctly in java. </p>
  
  <p>What I have so far is only working up to an imput of rows and columns to 9. </p>
  
  <p>For any two digit number or higher it's not displaying the map correctly as I don't have enough space. I could add to block let's say two blank spaces so the line numbering can go up to hundreds, but I'm trying to get a map that isn't restricted. </p>
  
  <p>Any help is much appreciated. 
  Here is what I have now: </p>
  
  <pre><code>public String toString() {
      String output;
      output = "gamemap:\n  ";
      for (int j = 0; j &lt; this.y; j++) { // loop over columns
          output += j;
      }
      output += "\n *";
  
      for (int j = 0; j &lt; this.y; j++) { // loop over columns
          output += "*";
      }
      output += "*\n";
  
      for (int i = 0; i &lt; this.x; i++) { // loop over rows
          output += i + "*";
          for (int j = 0; j &lt; this.y; j++) { // loop over columns
              output += this.map[i][j];
          }   
          output += "*\n"; 
      }
      output += " *";
  
      for (int j = 0; j &lt; this.y; j++) { // loop over columns
          output += "*";
      }
      output += "*\n";
  
      output += "The player has "+ this.player.lives + " lives left.";
      return output;
  }
  </code></pre>