Skip to content Skip to sidebar Skip to footer

Java Exception Invalid Int For Long Integer

I'm currently developing a math application that makes long computations. I'm getting java.lang.NumberFormatException: Invalid int: '...' error (where the ... is replaced by a very

Solution 1:

The maximum value for an int is 2-1, i.e. 2,147,483,647. If you try to parse a larger number than that, the exception will be thrown.

If you need to handle larger numbers, either use long for a generally larger range (up to 2-1) or BigInteger for an arbitrary size.

Solution 2:

Java's int datatype is limited to the values of -2,147,483,648 to 2,147,483,647 (inclusive). If you want larger 'integer' values I'd recommend using the long datatype.

Post a Comment for "Java Exception Invalid Int For Long Integer"