Tuesday, July 25, 2017

What happens when equating interegr wrapper clasees literals i.e Integer a and Integer b

/*What happens when equating interegr wrapper clasees literals i.e Integer a and Integer b,*/

package string;

public class Compare {

public static void main(String[] args) {

Integer a= 128;
Integer b = 128;

Integer a3= 127;
Integer b3 = 127;

int a1=129;
int b1=129;

System.out.println(a==b);
System.out.println(a3==b3);
System.out.println(128==128);
System.out.println(127==127);
System.out.println(a1==b1);

}

}

/* Output:
false
true
true
true
true
*/


No comments:

Post a Comment