title: Replacing in a 2D array in Java?
body: <p>In this program I am trying to create a coordinate plane and replace a value at a specific point. If the maximum value in the plane is 2, this code creates a 2D array with a max and minimum of 2 and numbers the axis like so:</p>
  
  <pre><code>String [][] grid = new String [max+max+2][max+max+2];
          for (int i=0; i&lt;max+max+1; i++)
              for (int j=0; j&lt;max+max+2; j++)
                  grid [i][j]="o";
  
          for (int i=0; i&lt;max+max+1; i++)
          {Integer Col=new Integer(max-i);
          grid [i][0]=Col.toString();}
  
          int [] firstRow= new int [max+max+1];
          for (int i=0; i&lt;firstRow.length; i++)
              firstRow [i]=max-max-max+i;
  
  ex:
     -2 -1  0  1  2
   2  o  o  o  o  o
   1  o  o  o  o  o
   0  o  o  o  o  o
  -1  o  o  o  o  o
  -2  o  o  o  o  o
  </code></pre>
  
  <p>In the following code an I receive random x,y coordinates for an airport (for this example say x=1 and y=-1). I have to replace the "o" in the double array with a "P" at this coordinate (1,-1). When I try to do this it is placing "P" at the correct x coordinate (1) but not at the correct y coordinate. There must be a problem with the second for loop, but I do not know what it is. The correct replacement should look like this:</p>
  
  <pre><code> ex:
         -2 -1  0  1  2
       2  o  o  o  o  o
       1  o  o  o  o  o
       0  o  o  o  o  o
      -1  o  o  o  P  o
      -2  o  o  o  o  o
  
  
  
          Integer airx = new Integer (airport1.getX());
          Integer airy= new Integer (airport1.getY());
          for (int i=0; i&lt;firstRow.length; i++)
              if (firstRow [i]==airport1.getX())
                  airx=i;
  
          String yCord= airy.toString();
          for (int k=0; k&lt;grid[0].length-1; k++)
              {String w =grid [k][0];
              if (w==yCord)
  
          for (int i=0; i&lt;grid[0].length-1; i++)
              if (grid [i][0]==airy.toString())
                  airy=i;
          grid [airy][airx+1]="A";
  </code></pre>