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 ...
随机推荐
- iframe的操作
获取iframe的window,获取Iframe的document,获取父页面的window,某个环境是否iframe,动态创建iframe 这是demo.html,这个页用iframe嵌入了ifra ...
- 第一次碰到try-except(core python programming 2nd Edition 3.6)
# coding: utf-8 # 使用Windows系统,首行'#!/usr/bin/env Pyton'无用,全部改为'# coding: utf-8' 'readtextfile.py -- r ...
- python产生随机名字
用到random.choice(序列) 在一个序列中随机选取一个值 import random as r a1=['张','金','李','王','赵'] a2=['玉','明','龙','芳','军 ...
- XJOI网上同步训练DAY3 T2
考试的时候已经想出来怎么做了,但是没有时间打了T_T 思路:我们考虑将询问以lim排序,然后树链剖分,把边作为线段树的节点,然后随着询问lim的增大,改变线段树中节点的信息,然后每次询问我们用树链剖分 ...
- jquery第六期:位置选择器
<html> <head> <script type="text/javascript" src="jquery-1.10.1.js&quo ...
- 【转】android cts failed items
原文网址:http://blog.csdn.net/linsa0517/article/details/19031479 Fail的一些修改 1.直接设置问题 estUnknownSourcesO ...
- c++ 12
一.模板与继承 1.从模板类派生模板子类 2.为模板子类提供基类 二.容器和迭代器 以链表为例. 三.STL概览 1.十大容器 1)向量(vector):连续内存,后端压弹,插删低效 2)列表(lis ...
- 【剑指offer】面试题28:字符串的排列
题目: 输入一个字符串,按字典序打印出该字符串中字符的所有排列.例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和cba. 输入描述:输入一 ...
- POJ3278 Catch That Cow(BFS)
Description Farmer John has been informed of the location of a fugitive cow and wants to catch her i ...
- 【POJ2196】Specialized Four-Digit Numbers(暴力打表)
一道水题,只要会复制粘贴就好! #include <iostream> #include <cstring> #include <cstdlib> #include ...