Java坑一
2024-10-19 02:24:18
public class Test { public static void main(String[] args) {
Integer a = 12;
Integer b = 12;
System.out.println(a == b);
System.out.println(a.equals(b));
a = 128;
b = 128;
System.out.println(a == b);
System.out.println(a.equals(b));
}
}
/**
* Cache to support the object identity semantics of autoboxing for values between
* -128 and 127 (inclusive) as required by JLS.
*
* The cache is initialized on first usage. The size of the cache
* may be controlled by the -XX:AutoBoxCacheMax=<size> option.
* During VM initialization, java.lang.Integer.IntegerCache.high property
* may be set and saved in the private system properties in the
* sun.misc.VM class.
*/ private static class IntegerCache {
static final int low = -128;
static final int high;
static final Integer cache[]; static {
// high value may be configured by property
int h = 127;
String integerCacheHighPropValue =
sun.misc.VM.getSavedProperty("java.lang.Integer.IntegerCache.high");
if (integerCacheHighPropValue != null) {
int i = parseInt(integerCacheHighPropValue);
i = Math.max(i, 127);
// Maximum array size is Integer.MAX_VALUE
h = Math.min(i, Integer.MAX_VALUE - (-low) -1);
}
high = h; cache = new Integer[(high - low) + 1];
int j = low;
for(int k = 0; k < cache.length; k++)
cache[k] = new Integer(j++);
} private IntegerCache() {}
}
最新文章
- java集合学生管理系统
- Mapped Statements collection does not contain value fo
- 【python】传入函数
- 【sinatra】安装测试
- Extjs4---Cannot read property &#39;addCls&#39; of null
- JSONObject和JSONArray
- 动动手,写个knockout的分页模板
- shape的使用
- CentOS tengine mysql 5.7 php 5.6
- CentOS下源码安装vsftpd-3.0.0,并设置指定用户访问指定目录(附带完整配置文件)
- 清橙A1212:剪枝
- SDCC2013大会笔记整理
- 微信小程序开发--第一个项目
- P4568 [JLOI2011]飞行路线
- ML: 降维算法-LDA
- 01-spark基础
- UI设计教程:如何在设计中运用颜色
- java 记录对象前后修改的内容(工具类)
- 使用c语言实现在linux下的openssl客户端和服务器端编程
- Delphi Xe4 游戏开发的技术选型.