Java

valueOf() 와 parseInt()

_침묵_ 2013. 3. 9. 23:38

출처: http://java67.blogspot.kr/2013/03/how-to-convert-java-string-to-int-or.html


우선 자바5 부터는 autoboxing이 되기 때문에 intInteger 사이의 변환은 그냥(?) 된다.


Integer.valueOf()와  Integer.parseInt()를 두고 본다면 Integer.valueOf()가 내부적으로 -128~127을 캐시하기 때문에 좀 더 유용하다. 그리고, 캐시에 자료가 없으면 Integer.parseInt()를 호출한다.


그렇다면, 실제로는 String이 -128~127인 경우에만 유용한게 아닌가?


'Java' 카테고리의 다른 글

Short UUID  (0) 2013.06.19
HttpURLConnection 사용시 http ~ https 간의 리다이렉션 처리  (0) 2013.01.03
Google Collections  (0) 2010.01.20