package com.common.packing;
public class Demo1 {
public static void main(String[] args) {
int num1 = 18;
Integer integer1 = new Integer(num1);
Integer integer2 = Integer.valueOf(num1);
System.out.println("装箱");
System.out.println(integer1);
System.out.println(integer2);
Integer integer3 = new Integer(100);
int num2 = integer3.intValue();
System.out.println("拆箱");
System.out.println(num2);
int age = 30;
Integer integer4 = age;
System.out.println("自动装箱");
System.out.println(integer4);
int age2 = integer4;
System.out.println("自动拆箱");
System.out.println(age2);
System.out.println("----------------基本类型和字符串之间转换------------------");
int n1 = 15;
String s1 = n1 + "";
String s2 = Integer.toString(n1);
String s3 = Integer.toString(n1,16);
System.out.println(s1);
System.out.println(s2);
System.out.println(s3);
String str = "150";
int n2 = Integer.parseInt(str);
System.out.println(n2);
String str2 = "true";
String str3 = "truu";
boolean b1 = Boolean.parseBoolean(str2);
boolean b2 = Boolean.parseBoolean(str3);
System.out.println(b1);
System.out.println(b2);
}
}
package com.common.packing;
public class Demo2 {
public static void main(String[] args) {
Integer integer1 = new Integer(100);
Integer integer2 = new Integer(100);
System.out.println(integer1 == integer2);
Integer integer3 = 100;
Integer integer4 = Integer.valueOf(100);
System.out.println(integer3 == integer4);
Integer integer5 = 200;
Integer integer6 = 200;
System.out.println(integer5 == integer6);
}
}