0
System.out.println(5 == new Integer(5)) output = true

Integer i31 = 2;
Integer i32 = new Integer(2);
System.out.println(i31 == i32); output = false

It rather seems since we are in function scope. hence different output. Unable to grasp what can be different.

utkarsh dubey
  • 875
  • 7
  • 19
  • 1
    `int==Integer` does value comparison. `Integer==Integer` does reference comparison. – khelwood Mar 23 '18 at 09:03
  • 1
    try `((int) i31) == i32` or `((Integer) 5) == new Integer(5)` - it's about (auto)boxing and unboxing and comparison of primitives and of references – user85421 Mar 23 '18 at 09:05

0 Answers0