프로그래밍

Wrapper class 감싼다

밍딩이 2015. 7. 31. 16:42

기본데이터 타입을 Wrapper타입으로 감싼다


boolean -> Boolean


byte -> Byte


char -> Character


int -> Integer



http://docs.oracle.com/javase/8/docs/api/index.html


(여기서 확인가능 )


java.lang



기본데이터 타입을 class로 만든다 ( heap 영역에 저장)


public class Test {

public static void main(String[] args) {

int a = 10;

//지역변수 

//이걸 클래스화 시키려면

Integer i = new Integer(a);

//인티저 클래스를 객체화 시킴

int b = i.intValue();

System.out.println(b);

}


}



b를 프린트하면

10이  나옴