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 ...
随机推荐
- Android中<meta-data>的使用
[转] 原文 在AndroidManifest.xml中,<meta-data>元素可以作为子元素,被包含在<activity>.<application> .& ...
- Xamarin Android 真机调试时闪退
方法1:引起此问题的原因一般是因为 Mono Shared Runtime 在手机上没有运行,这个程序相当于.net运行时,没有运行的话用C#开发的程序自然无法运行. 解决方法是将此程序设置为自动运行 ...
- LeetCode Remove Duplicate Letters
原题链接在这里:https://leetcode.com/problems/remove-duplicate-letters/ 题目: Given a string which contains on ...
- Oracle等待事件db file parallel read
SQL> select event#,name,parameter1,parameter2,parameter3 from v$event_name where name = 'db file ...
- 小谈pointer和relation
在apicloud的数据库中,pointer和relation是在很难让人理解. 通过不断的实践,终于有点明白了. pointer和relation作用:在nosql数据库中实现表之间的关联 首先来说 ...
- Java提高篇——equals()与hashCode()方法详解
java.lang.Object类中有两个非常重要的方法: 1 2 public boolean equals(Object obj) public int hashCode() Object类是类继 ...
- HTTPS与强制门户
强制门户 http://www.whatis.com.cn/word_5182.htm 强制网络门户(captive portal)是一个Web页面,它是使用公共访问网络的用户在被授予访问权限前必须访 ...
- RDIFramework.NET ━ 9.14 数据库连接管理 ━ Web部分
RDIFramework.NET ━ .NET快速信息化系统开发框架 9.14 数据库连接管理 -Web部分 我们经常可以看到很多软件直接把数据库连接字符串放在软件执行目录下的配置文件中,这种直接把 ...
- NULLIF()函数使用讲解
NULLIF()函数接受两个参数.如果它们相等,那么返回空值:否则,返回第一个参数. 等价于下面的表达式: case when expression1=expression2 then null el ...
- 时光煮雨 Unity3D实现2D人物动画② Unity2D 动画系统&资源效率
系列目录 [Unity3D基础]让物体动起来①--基于UGUI的鼠标点击移动 [Unity3D基础]让物体动起来②--UGUI鼠标点击逐帧移动 时光煮雨 Unity3D让物体动起来③—UGUI DoT ...