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
  • 349,597
  • 67
  • 533
  • 578
Topera
  • 12,223
  • 15
  • 67
  • 104

0 Answers0