My program includes a code segment as following:
for (int j1 =0; j1<2;j1++)
{
for (int j2 =0; j2<2;j2++)
{
System.out.println("j1="+j1+"j2="+j2+" "+temp1.get(j1)+"----"+temp2.get(j2));
if (temp1.get(j1)==temp2.get(j2))
{
System.out.println("find match");
}
}
}
The program prints out sth like
j1=0j2=0 7698380----7698380
the difference is 0
j1=0j2=1 7698380----7726365
the difference is -27985
j1=1j2=0 7726365----7698380
the difference is 27985
j1=1j2=1 7726365----7726365
the difference is 0
j1=0j2=0 7698380----7698380
the difference is 0
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
if (temp1.get(j1)==temp2.get(j2))
to
if (xyz == 0)
The result will look like
j1=0j2=0 7698380----7698380
the difference is 0
find match
j1=0j2=1 7698380----7726365
the difference is -27985
j1=1j2=0 7726365----7698380
the difference is 27985
j1=1j2=1 7726365----7726365
the difference is 0
find match
j1=0j2=0 7698380----7698380
the difference is 0
find match
The result is just what I expected. Can you let me know how does this happen? Thanks a lot.