int Integer == 地址 引用

	        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
		//int 类型的自动封装,与Integer声明的变量 总是指向同一地址
		//Integer声明的变量的值 在[-128,127]范围  地址指向相同(byte范围的数  是从常量池中获取,)
		//new Integer()是新建一个对象,与其他Integer的引用不同
		
		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
	
 
 

小结

int和任意Integer都是同一地址                        
Integer只在127范围内才是同地址,超出就false              
integer()与Integer,Integer()无论什么数范围 都不同地址   
                                           




猜你喜欢

转载自blog.csdn.net/qq_37609701/article/details/80084507