본문 바로가기

IT/자바

parseInt(), intValue()

출처 - http://vitalholic.tistory.com/72

intValue() Integer 객체에서 int형 값을 뽑아 내는 메소드


parseInt() String형 객체에서 int형 값을 뽑아 내는 메소드


출처 - https://m.blog.naver.com/PostView.nhn?blogId=welovebb&logNo=110095228824&proxyReferer=https%3A%2F%2Fwww.google.co.kr%2F


parseInt() 

    static 이다, 그러므로 Integer 생성안하고 parameter만 넣어주면 메소드를 수행할 수 있다.   

    string형 객체에서 int형 값을 뽑아내는 메소드이다. 

    문자형을 정수형으로 만든다.

 

    @ 예제

int i = Integer.parseInt(str);

 

intValue()

   static이 아니다, 그러므로 Integer 객체에서 int형 값을 뽑아내는 메소드이다.
    Integer는 (int Value와 String Value) 두가지가 있다. 

 

    @ 예제

int i = Integer.valueOf(str).intValue();

 

'IT > 자바' 카테고리의 다른 글

StringTokenizer, split,  (0) 2018.04.30
JAVA에서 자주 쓰이는 형변환  (0) 2018.04.29
String 불변2  (0) 2018.04.27
String 불변  (0) 2018.04.27
자바 String 객체 설명  (0) 2018.04.27