주제
문자를 숫자로 변환하는 과정에서 에러 발생
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
'etc' 카테고리의 다른 글
[notepad++] Windows 사용 중 .bak 파일이 자동으로 만들어 지는 이유, 중지하기 (0) | 2022.03.04 |
---|---|
[Java] Map 사용하기 - key, value, HashMap (0) | 2021.12.25 |
[Java] 문자열에서 원하는 단어 찾기 - indexOf() (0) | 2021.12.18 |
[Python] int(), String을 int로 바꿀때 에러 - SyntaxError: invalid token (0) | 2020.10.29 |
[Java] 현재 시간 한 줄로 표현하기 - SimpleDateFormat(), System.currentTimeMillis() (0) | 2020.09.10 |