int1 [Java] String to int, int to String 형 변환하기 ✏️ String to int 형변환하기(문자열을 숫자로) 1. Integer.parseInt() : 기본 자료형인 int를 리턴 class stringToInt { public static void main(String[] args) { String str = 123; int num = Integer.parseInt(str); System.out.println(num); // 결과 : 123 } } 2. Integer.valueOf() : 객체인 Integer Object를 리턴 class stringToInt { public static void main(String[] args) { String str = 123; int num = Integer.valueOf(str); System.out.prin.. 2024. 3. 13. 이전 1 다음