0

Out of curiosity: why do we have FALSE when the integer is greater than 127, for Integers?

public class Main {
    public static void main(String[] args) {
        System.out.println(127 == 127); // case 1: true
        System.out.println(128 == 128); // case 2: true
        System.out.println(Integer.valueOf(127) == Integer.valueOf(127)); // case 3: true
        System.out.println(Integer.valueOf(128) == Integer.valueOf(128)); // case 4: FALSE
    }
}
John Kugelman
  • 330,190
  • 66
  • 504
  • 555
Topera
  • 11,829
  • 14
  • 65
  • 101

0 Answers0