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

前端 未结 8 1615
一整个雨季
一整个雨季 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 22:57

    MAX_INT is 2147483647 and you're trying to parse a bigger number as Integer.

    You can use Long.parseLong instead:

    System.out.println(Long.parseLong("3020857508")); // 3020857508
    

提交回复
热议问题