Package com.day9.Wrapclass;
public class Demo {
public static void Main (string[] args) {
Integer i1 = new Integer (97);
Integer i2 = new Integer (97);
System.out.println (I1 = = i2);//false two objects, different address values
System.out.println (I1.equals (I2));//true
System.out.println ("-----------");
Integer i3 = new Integer (197);
Integer i4 = new Integer (197);
System.out.println (i3 = = i4);//false two objects, different address values
System.out.println (I3.equals (I4));//true
System.out.println ("-----------");
Integer i5 = 97;
Integer I6 = 97;
SYSTEM.OUT.PRINTLN (i5 = = I6);//true because the value range of byte is -128~127, if within this value range, automatic boxing will not
The newly created object is taken directly from the constant pool, and if a range of values is exceeded, the object is newly created
System.out.println (I5.equals (I6));//true
System.out.println ("-----------");
Integer i7 = 197;
Integer i8 = 197;
System.out.println (i7 = = i8);//false
System.out.println (I7.equals (i8));//true
}
}
Test of the Java-integer class