java – Integer. parseInt(“9999999990”);
•
Java
See English answers > unexpected numberformatexception while parsing a hex string to an int value 5
String str="9999999990"; int f = Integer.parseInt("2147483647");// No Exception here int x =Integer.parseInt(str); // Exception is thrown here
Solution
Integer. When parsing that it cannot be expressed as int ParseInt will throw an exception The first example is nearly 10 billion, which is greater than the maximum possible int, which is slightly higher than 2 billion
Integer. ParseInt (string) delegates to integer ParseInt (string, 10), that is, the version with cardinality, and the JavaDocs status:
(emphasize my)
If you need to parse it, you can use long Parselong, which will handle larger numbers
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码