I'm currently studying for the
SCJP exam (or OCP JSEP now maybe?) and am having issues with the objective that deals with Wrappers/Boxing. I understand that
Java sees Wrapper Objects as two separate objects and also as meaningful equal.
My question is why does it consider the Objects not equal if the value is large, but equal if the value is small? Shouldn't it see both as not equal since they are different objects? See below for the code I used to
test (this was done in TextPad).
Integer l4 = 3;
Integer l5 = 3;
Integer i3 = 1000;
Integer i4 = 1000;
void longtest()
{
if(l4 != l5) System.out.println("different objects @ 3"); //no output, makes sense
if(i3 != i4) System.out.println("different objects @ 1000"); //output?!?
}