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
반응형
'즐거운프로그래밍' 카테고리의 다른 글
[자바] 노트패드++ if~else 문(다중 if 문) (0) | 2023.10.13 |
---|---|
[자바] 노트패드++ if~else 문 (0) | 2023.10.13 |
[자바] 노트패드++ import 문 (0) | 2023.10.12 |
[자바] 노트패드++ 예제 2 (간접 접근 방식, private, 생성자 함수 등) (0) | 2023.10.12 |
[자바] 노트패드++ 예제 1 (직접 접근 방식) (0) | 2023.10.12 |