public class Test {
public static void main(String[] args) {
Integer a = new Integer(127);//cache(缓存)Java官方已经为我们创建好了
//我们可以直接使用不许再次创建[-127-127];
//cache(缓存)缓存机制可以帮助我们优化系统的性能,缓存机制就是事先准备好了的。
Integer d =127;
Integer b=127;
Integer s =new Integer(128);
Integer f =127;//自动装箱机制
System.out.println(a==d);
System.out.println(s==f);
System.out.println(d==b);
System.out.println(f+1);//+-*/会触发自动拆箱机制
//无论是否有相应数据的缓存,只要我们new就会创建新的对象,在堆内存中开辟新的存储空间;
}
}
Java Intege cache(缓存)
猜你喜欢
转载自blog.csdn.net/qq_45858803/article/details/121481289
今日推荐
周排行