本帖最后由 全海波 于 2012-9-4 17:55 编辑
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- //自动装箱
- Integer iObj =3;
- //自动拆箱
- System.out.println(iObj+12);
-
-
- Integer num1 = 12;
- Integer num2 = 12;
- System.out.println(num1==num2);//结果为 true
-
- Integer num3 = 129;
- Integer num4 = 129;
- System.out.println(num3==num4);//结果为false
-
- Integer num5 = Integer.valueOf(12);
- Integer num6 = Integer.valueOf(12);
- System.out.println("num5="+num5);
- System.out.println("num6="+num6);
- System.out.println(num6==num5);//true
-
- Integer num7 = Integer.valueOf(213);
- System.out.println("num7="+num7);
- System.out.println(num7.toString());
- Integer num8 = Integer.valueOf(213);
- System.out.println("num8="+num8);
- System.out.println(num8.toString());
- System.out.println(num7.equals(num8));//false
- //很简单,把“==”改成“equals”就行了,想想“==”与“equals”的区别!
- System.out.println(num7.toString()== num8.toString());//false
- }
复制代码 改之前,如下:
改之后,如下:
|