When comparing Integer objects, the == operator can only work for numbers between [-128,127]. Check out JLS :
If the value of p placed in the field is true, false, a byte or char in the range \ u0000 to \ u007f, or int or a short number between -128 and 127 (inclusive), then let r1 and r2 be the results of any two conversion conversion boxes . It always happens that r1 == r2.
Since these values ββthat you are comparing are not in the specified range, the result will be evaluated to false if you are not using Integer#equals .
source share