title: Overwriting an existing object in an Arraylist
body: <p>I have the object <code>DataEntry</code> with row, column, and value variables and I am trying to add a new object to an ArrayList unless there is already an object with the same row and column values then I overwrite the <code>value</code> with a new value right now i have this:</p>
  
  <pre><code>public void set(int row, int column, double val) {
          DataEntry temp = new DataEntry(row, column, val);
          for (int i = 0; i &lt; data.size(); i++)
              if (data.get(i).getRow() == row &amp;&amp; data.get(i).getColumn() == column)
                  data.set(i, temp);
              else {
                  data.add(temp);
              }
  }
  </code></pre>
  
  <p>It is not setting the value properly, i think it has something to do with <code>data.get(i).getRow()</code> </p>
  
  <p>Any help is appreciated</p>