ValueOf
-
[배운점] ParseInt() vs valueOf()Health-Genie 2023. 11. 29. 14:15
두개의 메소드 모두 String 을 Integer로 변경하기 위한 메소드이지만, 약간의 차이가 있다. parseInt 의 리턴 타입은 기본 자료형( int 타입 반환 ). [ 원시 데이터 int가 필요하면 이걸 쓴다 ] public static int parseInt(String s, int radix) throws NumberFormatException { return parseInt(s,radix); } valueOf 의 리턴 타입은 객체( Integer 래퍼 객체 반환 ). [ 객체 Integer가 필요하면 이걸 쓴다 ] public static Integer valueOf(String s, int radix) throws NumberFormatException { return Integer.val..