기본형을 객체로 다뤄야 하는 경우에 사용한다.
( ex. 매개변수로 객체를 요구할 때, 객체간의 비교를 할 때 )
기본형 래퍼클래스 생성자 boolean Boolean Boolean(boolean value)
Boolean(String s)char Character Character(char value) byte Byte Byte(byte value)
Byte(String s)short Short Short(short value)
Short(String s)int Integer Integer(int value)
Integer(String s)long Long Long(long value)
Long(String s)float Float Float(float value)
Float(String s)double Double Double(double value)
Double(String s)public class Main{ public static void main(String[] args) { Integer i = new Integer(100); Integer i2 = new Integer(100); //래퍼클래스 비교 System.out.println("i == i2"+ (i==i2)); System.out.println("i.equals(i2) = " + (i.equals(i2))); System.out.println("i.compareTo(i2) = " + (i.compareTo(i2))); //래퍼클래스가 가지고 있는 상수 System.out.println("MAX+_VALUE = "+Integer.MAX_VALUE); System.out.println("MIN+_VALUE = "+Integer.MIN_VALUE); System.out.println("SIZE = "+Integer.SIZE+"bits"); System.out.println("BYTES = "+Integer.BYTES+"bytes"); System.out.println("TYPE = "+Integer.TYPE); } } /* 출력 : i == i2false i.equals(i2) = true i.compareTo(i2) = 0 MAX+_VALUE = 2147483647 MIN+_VALUE = -2147483648 SIZE = 32bits BYTES = 4bytes TYPE = int */