주제

 

문자를 숫자로 변환하는 과정에서 에러 발생

java.lang.NumberFormatException: For input string:

 

 

 

 해결

 

Integer의 최대값(MAX_VALUE) 2147483647를 초과해서 생긴 문제이다.

 

Integer의 최소값은 -2³¹

-2,147,483,648

 

Integer의 최대값은 2³¹

2,147,483,647

 

 

Double을 사용하면 해결된다.

 

Integer.parseInt()

==> 변경

Double.parseDouble()

 

 

 출처

 

오라클 자바 문서

Class Integer

 

static int MAX_VALUE
A constant holding the maximum value an int can have, 2³¹-1.

static int MIN_VALUE
A constant holding the minimum value an int can have, -2³¹.

https://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html

 

 

 

Class Double

 

https://docs.oracle.com/javase/8/docs/api/java/lang/Double.html

 

 

728x90

+ Recent posts