모든 래퍼 클래스의 부모는 Object, 모든 래퍼 클래스는 최종 클래스로 정의

박싱(Boxing) : 기본 자료형(Primitive data type)의 값을 Wrapper class로 만드는 과정
언박싱(UnBoxing) : Wrapper class에서 기본 자료형(Primitive data type)의 값을 얻어내는 과정
Wrapper_Ex
public class Wrapper_Ex {
public static void main(String[] args) {
Integer num = new Integer(17); // 박싱
int n = num.intValue(); //언박싱
System.out.println(n);
}
}
JDK 1.5 부터는 AutoBoxing과 AutoUnBoxing을 제공한다.
이 기능은 각 Wrapper class에 상응하는 Primitive data type일 경우에만 가능하다.
Ex) int 타입의 값을 Integer class에 대입하면 AutoBoxing이 일어나 Heap 영역에 Integer 생성
public class Wrapper_Ex {
public static void main(String[] args) {
Integer num = 17; // 자동 박싱
int n = num; //자동 언박싱
System.out.println(n);
}
}