Description:
public class Test1 { public static void main(String[] args) { Integer i = new Integer(201); Integer j = new Integer(201); if(i == j) { System.out.println("hello"); } else { System.out.println("bye"); } } }
Solution:
Output
bye
Explanation
The Integer class caches integer values from -127 to 127. Therefore, the Integer objects can only be created in the range -128 to 127. The operator == will not work for the value greater than 127; thus bye is printed.