Integer
import static java.lang.System.*;
public class IntegerTestOne{
public static void main(String []args){
Integer in1=new Integer(6);
Integer in2=new Integer(6); Integer in3=6;
Integer in4=6;
//Integer in4=Integer.valueOf(6);
//也可以采用valueOf()方法来创建Integer对象,同样也会缓存该方法创建的对象 int in5=6;
int in6=6; Integer in7=222;
Integer in8=222; out.println(in1==in2);//Integer类使用new方法生成的不是同一个对象
out.println(in3==in4);//原则上不能直接赋值给一个Integer对象,但JDK 1.5后自动将基本数据类型转化为对应的封装类型
out.println(in5==in6);//in6的地址指向in5
out.println(in7==in8);// Integer只缓存-128~127之间的Integer对象 }
}
false
true
true
false
http://www.cnblogs.com/shenliang123/archive/2012/04/16/2451996.html
Integer的更多相关文章
- LeetCode 7. Reverse Integer
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Have you ...
- Integer.parseInt 引发的血案
Integer.parseInt 处理一个空字符串, 结果出错了, 程序没有注意到,搞了很久, 引发了血案啊!! 最后,终于 观察到了, 最后的部分: Caused by: java.lang.NoC ...
- 由一个多线程共享Integer类变量问题引起的。。。
最近看到一个多线程面试题,有三个线程分别打印A.B.C,请用多线程编程实现,在屏幕上循环打印10次ABCABC- 看到这个题目,首先想到的是解决方法是定义一个Integer类对象,初始化为0,由3个线 ...
- [LeetCode] Integer Replacement 整数替换
Given a positive integer n and you can do operations as follow: If n is even, replace n with n/2. If ...
- [LeetCode] Integer Break 整数拆分
Given a positive integer n, break it into the sum of at least two positive integers and maximize the ...
- [LeetCode] Integer to English Words 整数转为英文单词
Convert a non-negative integer to its english words representation. Given input is guaranteed to be ...
- [LeetCode] Roman to Integer 罗马数字转化成整数
Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 t ...
- [LeetCode] Integer to Roman 整数转化成罗马数字
Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...
- [LeetCode] String to Integer (atoi) 字符串转为整数
Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. ...
- [LeetCode] Reverse Integer 翻转整数
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to ...
随机推荐
- busybox rootfs 启动脚本分析(一)
imx6文件系统启动脚本分析.开机运行/sbin/init,读取/etc/inittab文件,进行初始化. 参考链接 http://blog.163.com/wghbeyond@126/blog/st ...
- WebService 学习
WebService是一种跨编程语言和跨操作系统平台的远程调用技术. XML+XSD, SOAP 和 WSDL 是构成WebService平台的三大技术. SOAP = HTTP协议 + XML数据格 ...
- iOS应用架构谈 网络层设计方案
网络层在一个App中也是一个不可缺少的部分,工程师们在网络层能够发挥的空间也比较大.另外,苹果对网络请求部分已经做了很好的封装,业界的AFNetworking也被广泛使用.其它的ASIHttpRequ ...
- PRAGMA AUTONOMOUS_TRANSACTION
转自 http://blog.csdn.net/pan_tian/article/details/7675800 这段时间遇到一个问题,程序里明明插入了一条记录,但在后边的一段Procedure中却查 ...
- iOS:融云即时通讯快速集成
一.介绍 即时通讯在众多社交软件.生活软件以及教育软件中已经是必备的功能了,在当前国内,即时通讯SDK做的比较不错的有那么几家,例如环信SDK.融云SDK...,这两家做的都很不错,各有千秋吧,要是真 ...
- 如何在断开ssh连接后仍然保持服务器正常运行程序
问题描述:当SSH远程连接到服务器上,然后运行一个Python程序(bpr.py),然后把终端开闭(切断SSH连接)之后,发现该程序执行中断. 解决方法:使用nohup命令让程序在关闭窗口(切换SSH ...
- linux的命令
Linux命令的分类 选项及参数的含义 以"-"引导短格式选项的(单个字符),例如"-l" 以"--"引导长格式选项(多个字符),例如&qu ...
- The type XXX cannot be resolved. It is indirectly referenced from required .class files错误.....
遇到The type XXX cannot be resolved. It is indirectly referenced from required .class files错误.....,查找的 ...
- Java连接Redis (key-value存储系统)
Redis简介: redis是一个性能非常优秀的内存数据库,通过key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表). ...
- SQL2005中的事务与锁定(七) - 转载
------------------------------------------------------------------------ -- Author : HappyFlyStone - ...