The following code prints "true, true, false, true". Shouldn't it be "true, true, true, true"?

Posted by Sanjeev on Stack Overflow See other posts from Stack Overflow or by Sanjeev
Published on 2010-03-23T12:57:12Z Indexed on 2010/03/23 13:03 UTC
Read the original article Hit count: 349

Filed under:
Integer i = 127;
Integer j = 127;
System.out.println(i == j);
System.out.println(i.equals(j));

Integer i1 = 128;
Integer j1 = 128;
System.out.println(i1 == j1);
System.out.println(i1.equals(j1));

I don't understand why its not print "true, true, true, true". please give answer?

© Stack Overflow or respective owner

Related posts about java