Java中a(100)==b(100)为ture,a(1000)!=b(1000)

public class Test {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Integer a=100,b=100;
		Integer c=1000,d = 1000;
		if(a==b)System.err.println("a==b为true");//integer内部缓存-128——127的都是同一对象
		if(c==d)System.err.println("c==d为true");
		
	}

}

发布了20 篇原创文章 · 获赞 1 · 访问量 416

猜你喜欢

转载自blog.csdn.net/XMY_UPUPUP/article/details/104723697
今日推荐