自动装箱和拆箱
package com.itheima;
public class IntegerDemo {
public static void main(String[] args) {
// 自动装箱
Integer i = 10; // 相当于: Integer i = new Integer(10);
// 自动拆箱
Integer j = 10; // 相当于: Integer j = new Integer(10);
int a = j; // 相当于: int a = j.intValue();
}
}
例如:
Integer i = 10;
Integer i2 = 20;
Integer i3 = i + i2;
/*
相当于:Integer i3 = new Integer(i.intValue() + i2.intValue());
*/