Java坑一
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坑一的更多相关文章
- 初入Java坑,然后又入产品坑
之前工作了一年,从事Java相关工作,不小心深得领导器重,跑去演讲.写文档.与客户沟通等,最后应公司需要,转往产品坑,坑坑相连,何时逃坑. 最近一直在学习产品经理必备工具Axure,发现这真是一个神奇 ...
- java坑之无法创建线程
环境:linux 错误:java.lang.OutOfMemoryError: unable to create new native thread 原因:OS对线程是有限制 解决办法: 在Linux ...
- java 坑
时间戳 unix的时间戳和java中的是不同的.unix为10位,java的13位.需要进行转换. long timestamps = 1509783992L; long javaTimstamps ...
- 一个奇妙的java坑:Long 类型的比较
Long userId=127L; Long authorId=127L; System.out.println(userId==authorId);//true userId=128L; autho ...
- java 坑总结
1.Cannot find current proxy: Set 'exposeProxy' property on Advised to 'true' to make it available. 解 ...
- 新手上路之如何选择Java版本
@ 目录 LTS与非LTS LTS 非LTS Java CPU与PSU Java SE.Java EE.Java ME的区别 Java SE Java EE Java ME 每一次JDK上新总有一群人 ...
- 10天,从.Net转Java,并找到月薪2W的工作(三)
放弃Offer之后,压力一天比一天打 好点的公司,除了技术追根问底,还对你平时代码实践问的很多.比如问你,redis缓存一般设置多大.问你项目内容的细节,业务流程. 集合.锁.Jvm.多线程高并发.微 ...
- DES & 3DES 加密算法
JAVA坑 跟其他公司java的对接口,一个细节对到吐血,具体: DesUtil.java(别人的反例) //package base_class; import java.io.IOExceptio ...
- Mybatis Dynamic Query 2.0.2
项目地址:https://github.com/wz2cool/mybatis-dynamic-query 文档地址:https://wz2cool.gitbooks.io/mybatis-dynam ...
随机推荐
- JSONP有什么作用
1.解决跨域访问数据 由于同源策略的限制,XmlHttpRequest只允许请求当前源(域名.协议.端口)的资源,为了实现跨域请求,可以通过script标签实现跨域请求 ...
- javascript 过滤空格
1: 过滤首尾空格trim.2:过滤左边空格ltrim 3:过滤右边空格 用正则方法写成三个函数. <script type="text/javascript"> ...
- phpwind 去除init.phpwind.net统计功能
修改的文件如下:global.phplib/staticpage.class.phprequire/template.phpsimple/index.php
- 存储过程--表变量和while简单运用
1.sql创建表/*订单*/CREATE TABLE Orders ( PRIMARY KEY(Id), Id int, Name varchar(20))2.存储过程ProTestDT 1)创 ...
- js 浮点数加减问题
/** ** 加法函数,用来得到精确的加法结果 ** 说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显.这个函数返回较为精确的加法结果. ** 调用:accAd ...
- 一些80C51单片机支持双DPTR,C编译器是如何使用它的?
在C51中,C编译器并不利用双DPTR来优化用户所写的程序,只有一些库例程使用了双数据指针.当在两个存储器块之间进行数据复制或比较时,以下库例程会使用双数据指针: memmovememcpymemcm ...
- 操作系统对的IIS版本
IIS版本 Windows版本 备注 IIS 1.0 Windows NT 3.51 Service Pack 3 IIS 2.0 Windows NT 4.0 IIS 3.0 Windows ...
- C/C++ 指针的非空判断
一定要分得清楚C和C++的“空指针常量”不是一样的.C标准不保证NULL等于0,所以做指针非空判断时,应该用if(p != NULL):因为“上下文转换到bool值”的统一性,C++就应该用if(p) ...
- 【转】git与github在ubuntu下的使用 -- 不错
原文网址:http://www.cnblogs.com/cocowool/archive/2010/10/19/1855616.html 最近开始使用git对kohana3的文档做一些补充的工作,使用 ...
- JS代码的window.location属性详解
转载:http://www.5icool.org/a/201105/a564.html 如果你稍微懂一些JS代码,一般都会知道 window.location.href 这个属性.并且用该属性获取页面 ...