parseInt2 10진수를 2진수, 8진수, 16진수로 변환 소스 코드 public class Main { public static void main(String[] args) { // 10진수 int num = 120; String decimalToBinary = Integer.toBinaryString(num); String decimalToOctal = Integer.toOctalString(num); String decimalToHex = Integer.toHexString(num); System.out.println("10진수 -> 2진수, 8진수, 16진수로 변환"); System.out.println("10진수: " + num + ", 2진수: " + decimalToBinary); System.out.println("10진수: " + num + ",.. 2019. 4. 7. Integer 클래스 valueOf, parseInt 메서드 차이점 Integer 클래스에는 valueOf, parseInt 메서드가 있다. 두 메서드는 매개 변수로 전달 받은 문자열(String) 값을 정수 형태로 반환다. 메서드 시그니처를 살펴보면, 두 메서드의 차이는 리턴 타입이 다르다는 것을 알 수 있다. valueOf 메서드 valueOf 메서드는 Integer 객체를 반환한다. 그리고 내부적으로 parseInt 메서드를 사용한다. public static Integer valueOf(String s) throws NumberFormatException { return Integer.valueOf(parseInt(s, 10)); } parseInt 메서드 parseInt 메서드는 기본 자료형 int를 반환한다. 오버로딩 메서드 내부적으로 parseInt(s, 1.. 2019. 4. 4. 이전 1 다음