A problem on using x==Y or (x-y)==0 to control the if condition
<p>My program includes the following code segment, which do sth based on whether two variables, temp.get(j1) and temp(j2) are equivalent or not.</p>

<pre><code>  for (int j1 =0; j1&lt;2;j1++)
  {
      for (int j2 =0; j2&lt;2;j2++)
      {
       System.out.println("j1="+j1+"j2="+j2+" "+temp1.get(j1)+"----"+temp2.get(j2));
       int xyz = temp1.get(j1)-temp2.get(j2);
       System.out.println("the difference is "+ xyz);

       if (temp1.get(j1)==temp2.get(j2))
       {
           System.out.println("find match");
       }
      }
  }
</code></pre>

<p>The program prints out sth like</p>

<p>j1=0j2=0 7698380----7698380</p>

<p>the difference is 0</p>

<p>Even the two values, temp1.get(j1) and temp2.get(j2) do overlap, the "if" part just did not go through. If I change the <code>if (temp1.get(j1)==temp2.get(j2))    to 
      if (xyz == 0)</code></p>

<p>Then the result will look like</p>

<p>j1=0j2=0 7698380----7698380</p>

<p>the difference is 0</p>

<p>find match
`</p>

<p>I think the two conditions for controlling the if loop should be the same, why the result if so different? Thanks a lot for the answer.</p>
