2

getting an Exception in thread "main" java.lang.NumberFormatException: For input string: "8801609054" even though it can properly read the format.

I'm using

Integer.parseInt("8801609054");

to do this. I've found people with similar error usually had null or empty values but this one has a value so I'm not sure where the error is coming from.

3
  • 2
    The literal 8801609054 of type int is out of range Commented May 19, 2021 at 7:12
  • 1
    largest possible integer is 2147483647 Commented May 19, 2021 at 7:12
  • Use a long or a BigInteger here... Alternative: BigDecimal Commented May 19, 2021 at 7:17

2 Answers 2

2

The number you passed as a string is too large. The largest integer allowed is Integer.MAX_VALUE (2147483647). Maybe you should work with BigDecimal instead.

Sign up to request clarification or add additional context in comments.

Comments

1

8801609054 is larger than the maximum integer value (primitive int) in Java. You can compare it with Integer.MAX_VALUE and confirm.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.