즐거운프로그래밍

[자바] 노트패드++ Wrapper 클래스

수수께끼 고양이 2023. 10. 12. 18:03
728x90
반응형

 

Wrapper 클래스 : 문자열을 기본 데이터 형으로 변환하기 위한 클래스

 

public class ImportExam { 
	public static void main(String args[]) {
			String strNum = "2005";
			String strBool = "true";
			
		int intNum = Integer.parseInt(strNum);
		float floatNum = Float.parseFloat(strNum);
		Boolean boolObj = Boolean.valueOf(strBool);
		boolean bool = boolObj.booleanValue();
		
		System.out.println("Integer.parseInt(strNum) -> " + intNum);
		System.out.println("Float.parseFloat(strNum) -> " + floatNum);
		System.out.println("Boolean.getBoolean(strBool) -> " + bool);
	}
}

 

 

 

728x90
반응형