title: Creating a reference in Java
body: <p>I want to use a reference as a shorthand to an array element, where the array consists of elements of a basic type (integers). How can I explicitly create a reference in Java? Is it possible?</p>
  
  <pre><code>/* ... */
  //neighbors = new int[][]
  //I'm using neighbor, below, to refer to an element in neighbors so that the code
  //is easier to read. I want it to be a reference so that I can write to it.
  int neighbor = neighbors[y][x]; 
  
  if (neighbor == 0)
      btn.setText("");
  else
      btn.setText("" + neighbor);
  
  if (btn.isEnabled() == true) {
      numSquaresRevealed++;
      btn.setEnabled(false);
  }
  
  //I want neighbor to be a reference so that I can be consistent and use it below
  if (changeNeighbors)
      neighbors[y][x] = -1;
  /* ... */
  </code></pre>