int Integer == address reference

	        int a5 = 127;
		Integer a6 = 127;
		Integer a61 =127;
		Integer a7 =new Integer(127);
		System.out.println(a5==a6);//true
		System.out.println(a5==a7);//true

		System.out.println(a6==a61);//true
		System.out.println(a6==a7);//false
		//Automatic encapsulation of int type, variables declared as Integer always point to the same address
		//The value of the variable declared by Integer points to the same address in the [-128,127] range (the number in the byte range is obtained from the constant pool,)
		//new Integer() is to create a new object, which is different from other Integer references
		
		int a0 = 1280;
		int a01 = 1280;
		Integer a3 =1280;
		Integer a4 =1280;
		System.out.println(a0==a01);//true
		System.out.println(a0==a3);//true
		System.out.println (a3 == a4); // false
	
 
 

summary

Int and any Integer are the same address.                        
Integer is the same address only in the range of 127. If it exceeds the range, it is false              
. Integer and Integer, Integer() have different addresses no matter what the number range is.   
                                           




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324887086&siteId=291194637