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 ...
随机推荐
- 修改ArcGIS Server Account / 站点管理员的 账号、密码
安装ArcGIS Server(10.1之后版本)时会先后创建两个账户:ArcGIS Server Account和站点管理账户 ArcGIS Server Account 是操作系统账户,Serve ...
- (IOS)BaiduFM 程序分析
本文主要分享下楼主在学习Swift编程过程中,对GitHub上的一个开源app BaiduFM的研究心得. 项目地址:https://github.com/belm/BaiduFM-Swift 一.项 ...
- mac显示所有文件、不产生.DS_Store文件
1.mac的Finder显示所有文件: defaults write com.apple.finder AppleShowAllFiles -bool true killall Finder 2.ma ...
- JMeter学习-021-JMeter 定时器(Synchronizing Timer)之集合点应用
性能测试中我们经常提到一个概念就是“并发”,其实在实际真实的性能测试中是不存在真正的并发的.为了更真实的模拟对一个请求的并发测试场景,我们通常设置一个集合点,JMeter中提供了这样的一个功能设置. ...
- wpa gui
wpa gui是wpa_supplicant的ui工具. wpa_supplicant源码中包含了wpa_gui, 在目录wpa_gui-qt4中. 先运行wpa supplicant,再运行wpa ...
- 【Apache】apache简单配置URL重写规则
[概述]URL重写就是首先获得一个进入的URL请求然后把它重新写成网站可以处理的另一个URL的过程.举个例子来说,如果通过浏览器进来的URL是index.php?type=news&& ...
- jquery判断页面是否滑动到最底部
// 滚动到底部,向下的箭头消失 var $down = $('.down'); var $window = $(window); var $document = $(document); $wind ...
- Java -- 在Eclipse上使用Spring
在.NET上用的VS.NET+Spring.net+Nhibernate,到了Java平台上,自然对应着Eclipse+Spring+Hibernate.上一篇文章介绍了如何在Eclipse上使用Hi ...
- jqgrid如何在一个页面点击按钮后,传递参数到新页面
利用 Content/Scripts/dw-framework.js 中的AddTableMenu属性 <div class="Task" style="backg ...
- Struts2 配置详解
1. web.xml 此文件的配置可以参看struts2的示例文档 <filter> <filter-name>struts2</filter-name> < ...