Exception java. lang. NumberFormatException: For input string:, exception forinputstring
When writing a project today, this exception occurs when converting the String type to the Integer type. The record is as follows:
The Code is as follows:
1 String a = "2222222222"; // 10 22 Integer B = Integer. valueOf (a); // converts String type to Integer type
The exception is as follows:
Cause & Solution: Integer in a 32-bit compiling environment, the storage length is 32 bits. -2 ^ 31 ~ 2 ^ 31-1;-2,147,483,648 ~ 2,147,483,647. Replace Integer with BigInteger to solve the problem.
The Code is as follows:
String a = "2222222222"; // It is also 10 2 BigInteger B = new BigInteger (a); // String to BigInteger
The important thing is said three times:
You are welcome to point out errors and errors, and make suggestions. I will update them in my blog in time!
You are welcome to point out errors and errors, and make suggestions. I will update them in my blog in time!
You are welcome to point out errors and errors, and make suggestions. I will update them in my blog in time!