Integer.parse(String str) java.lang.NumberFormatException: Errors

前端 未结 8 1611
一整个雨季
一整个雨季 2020-12-11 22:18

I keep getting number format expectations, even though I\'m trimming the strings and they don\'t contain non numerical characters bizarrely it works for some numbers and not

8条回答
  •  一整个雨季
    2020-12-11 23:06

    The largest number parseable as an int is 2147483647 (231-1), and the largest long is 9223372036854775807 (263-1), only about twice as long.

    To parse arbitrarily long numbers, use:

    import java.math.BigInteger;
    
    BigInteger number = new BigInteger(str);
    

提交回复
热议问题