[JAVA] Wrapper 예제_1

정은아·2022년 7월 25일
package ja_0725;

public class Wrapper_1 {
	public static void main(String[] args) {
		
		Integer one = new Integer("345");
		Integer two = new Integer(45);
		
		int total = one.intValue() + two.intValue(); 
		String totalString = one.toString() + two.toString(); 
		
		System.out.println("one : "  + one.intValue() + ", two : " + two.intValue());
		System.out.println("one : " + one + ", two : " + two);
		
		System.out.println("one + two : " + total);
		System.out.println("one.toString() + two.toString()" + totalString);
		
		System.out.println(total + " >> 2진수 : " + Integer.toBinaryString(total));
		System.out.println(total + " >> 8진수 : " + Integer.toOctalString(total));
		System.out.println(total + " >> 16진수 : " + Integer.toHexString(total));
	
		System.out.println(Integer.TYPE);
	}
}
int total = one.intValue() + two.intValue(); 

은 숫자 덧셈을 나타내는 출력문입니다.

String totalString = one.toString() + two.toString();

은 문자덧셈을 나타내는 출력문입니다.

profile
꾸준함의 가치를 믿는 개발자

0개의 댓글