Reputation: 55
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.
Upvotes: 2
Views: 219
Reputation: 81
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.
Upvotes: 2
Reputation: 25950
8801609054 is larger than the maximum integer value (primitive int) in Java. You can compare it with Integer.MAX_VALUE
and confirm.
Upvotes: 1