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的更多相关文章

  1. LeetCode 7. Reverse Integer

    Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Have you ...

  2. Integer.parseInt 引发的血案

    Integer.parseInt 处理一个空字符串, 结果出错了, 程序没有注意到,搞了很久, 引发了血案啊!! 最后,终于 观察到了, 最后的部分: Caused by: java.lang.NoC ...

  3. 由一个多线程共享Integer类变量问题引起的。。。

    最近看到一个多线程面试题,有三个线程分别打印A.B.C,请用多线程编程实现,在屏幕上循环打印10次ABCABC- 看到这个题目,首先想到的是解决方法是定义一个Integer类对象,初始化为0,由3个线 ...

  4. [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 ...

  5. [LeetCode] Integer Break 整数拆分

    Given a positive integer n, break it into the sum of at least two positive integers and maximize the ...

  6. [LeetCode] Integer to English Words 整数转为英文单词

    Convert a non-negative integer to its english words representation. Given input is guaranteed to be ...

  7. [LeetCode] Roman to Integer 罗马数字转化成整数

    Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 t ...

  8. [LeetCode] Integer to Roman 整数转化成罗马数字

    Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 t ...

  9. [LeetCode] String to Integer (atoi) 字符串转为整数

    Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. ...

  10. [LeetCode] Reverse Integer 翻转整数

    Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to ...

随机推荐

  1. Mac配置

    1.显示Mac隐藏文件的命令: defaults write com.apple.finder AppleShowAllFiles -bool true 2.Mac键盘如何开启键盘上F1 - F12功 ...

  2. java中遍历集合的三种方式

    第一种遍历集合的方式:将集合变为数组 package com.lw.List; import java.util.ArrayList; import java.util.List; import ja ...

  3. React学习一

    一.运行起来react 1.引入react库 引入对应的js即可,第三方cdn引入 <script src="https://cdnjs.cloudflare.com/ajax/lib ...

  4. CSS之cssText

    更改元素样式 <div style="width:100px;height:100px;text-align:center;line-height:100px;"> T ...

  5. python 操作消息队列

    图示 其中P指producer,即生产者:C指consumer,即消费者.中间的红色表示消息队列,实例中表现为HELLO队列. 往队列里插入数据前,查看消息队列 $sudo rabbitmqctl l ...

  6. HTML form enctype 属性试验

    HTML form enctype http://www.w3.org/TR/html401/interact/forms.html#h-17.13.1%E2%80%8D enctype= conte ...

  7. NET基础(2):类型转换

    CLR最重要的特性之一就是类型安全的.在运行时,CLR总是知道对象的类型是什么.调用GetType()方法可以知道对象的确切类型,由于它是非虚方法,所以一个类型不可能伪装成另一种类型.每种编程语言都规 ...

  8. struts action和jsp之间的传值

    一.jsp对Action传值 提交表单即可,Action的属性必须和表单的标签名字相同 二.Action对jsp传值: (1)利用session,(个人推荐) action中ActionContext ...

  9. C# 窗体

    窗体的事件:删除事件:先将事件页面里面的挂好的事件删除,再删后台代码里面的事件 Panel是一个容器 1.Label -- 文本显示工具Text:显示的文字取值.赋值:lable1.Text 2.Te ...

  10. PeopleTools预警程序制作

    预警程序的概念:在主页上显示一个查询的结果.这个查询就是一个Record. 一.在Application Designer建一个项目,包含所有需要的Record. CUX_REC_BLRY Recor ...