Just give the example above a try and see for yourself.
kind regards,
Jos (old bag of old tricks ;-)
Ok, so I tried the following:
[code=java]
public class testSomething {
public static void main(String args[]) {
Integer a = 42, b = 42;
Integer c = 129, d = 129;
System.out.prin tln( a == 42 ); // true
System.out.prin tln( a == b ); // true
System.out.prin tln( c == 129 ); // true
System.out.prin tln( d == 129 ); // true
System.out.prin tln( c == d ); // false
System.out.prin tln( c.intValue() == d.intValue() ); // true
}
}
[/code]
I can only assume from the information thus far that after one byte's value (signed) or at a value greater then or equal to 128 Integer no longer stores its numbers the same way... I do not know why or how.
I'm trying to think of some other tests to try and understand this...
I didn't try it... but why does 142 == 142 output false? Btw, is autoboxing the process which checks "=="? I'm confused...
-blazed
check this code
Integer a = 42, b = 42;
Integer c = 3, d = 3;
System.out.prin tln( a == 42);
System.out.prin tln( a == b );
System.out.prin tln( c == 3 );
System.out.prin tln( c == d );
Integer a = 42, b = 42;
Integer c = 3, d = 3;
System.out.prin tln( a == 42);
System.out.prin tln( a == b );
System.out.prin tln( c == 3 );
System.out.prin tln( c == d );
Comment