This example will print only Not
When i change a and b=100 it only show "Yes"
Integer class with value from -128 to 127 in
Java pools
Integer i1 = -128;
Integer i2 = -128;
i1==i2 - true, because i1 and i2 from pool
Integer i1 = -129;
Integer i2 = -129;
i1==i2 - false
Integer i1 = 127;
Integer i2 = 127;
i1==i2 - true, because i1 and i2 from pool
Integer i1 = 128;
Integer i2 = 128;
i1==i2 - false
But
Integer i1 = new Integer(127);
Integer i2 = new Integer(127);
i1==i2 - false, because i1 and i2 create at Runtime, not from pool