title: JAVA : How can I represent a 2D character array as a String using a toString ?
body: <p>I am making a program using the LRV(Least recently visited) Algorithm.
  Basically, I design the algorithm for a robot to traverse through a grid (which is a 2D char array). The robot whilst traversing the grid checks whether each cell is either EMPTY (defined by '-'), OCCUPIED ( defined by 'O' ) or BLOCKED (defined by 'X').
  The cells can only be occupied by an object known as Sensor (this has its own class).
  BLOCKED cells cannot be traversed on.
  Each time the robot must move, it receives a direction from the sensor. So in the beginning the robot would be placed on the grid and it would drop a sensor and get a direction from it, or get a direction from a pre-existing sensor.</p>
  
  <p>Now that I've explained my program,
  my specific question is, I have my GridMap class</p>
  
  <pre><code>public class GridMap {
    private int height;
    private int width;
    private char[][] grid;
  
  
    public GridMap(int x, int y) { 
      height=x;
      width=y;  
      grid = new char [x][y];
    }
    public int getHeight(){
      return height;
    }
    public int getWidth(){
      return width;
    }
    public String toString(){
      String s1 = 
      return s1;
    }
    public char getElementAt(int x, int y){
    }
    public void setElementAt(int x, int y){
    }
    public boolean isCellBlocked(int x, int y){
    }
    public double getCoverageIndex(){
      return COVERAGE_INDEX;
    }
  }
  </code></pre>
  
  <p>What I want to know is how can I represent my 2D char array as a string of -, O's and X's.
  I tried to be as detailed as possible, if anyone has any questions I'd be willing to answer asap.
  Any help will be highly appreciated.
  Thanks</p>
  
  <p>Varun</p>