title: Setting a char value to a 2d array
body: <p>I am making a <code>3x3</code> matrix using a 2d array. The array will initially display all <code>-</code>. Afterwhich I try to update the some values of the array to <code>1</code> and <code>2</code>. But the display still shows all <code>-</code> without updating the values of the array.</p>
  <pre class="lang-java prettyprint-override"><code>private char[][] matrix;
  
  public Matrix() {
      matrix = new char[3][3];
  }
  
  // setter and getter
  public void set(int rowIndex, int colIndex, char data) {
      matrix[rowIndex][colIndex] = data;
  }
  
  public int get(int rowIndex, int colIndex) {
      return matrix[rowIndex][colIndex];
  }
  
  // display the matrix
  public void display() {
      for (int i = 0; i &lt; matrix.length; i++) {
          for (int j = 0; j &lt; matrix.length; j++) {
              matrix[i][j] = '-';
              System.out.print(matrix[i][j]);
          }
          System.out.println();
      }
  }
  
  public static void println(String message) {
      System.out.println(message);
  }
  
  public static void main(String[] args) {
      Matrix matrix = new Matrix();
      matrix.display();
      matrix.set(0, 0, '1');
      matrix.println(&quot;&quot;);
      matrix.display();
      matrix.set(0, 1, '2');
      matrix.println(&quot;&quot;);
      matrix.display();
  }
  </code></pre>