一個字符串轉換爲一個整數值,當我試圖解析字符串輸入1到一個整數值它崛起的一個NumberFormatException.I've試圖如有替換字符串中的空間,但事實並非如此爲我工作。NumberFormatException異常而在Java
int number = 0;
String input1 = "12345354987";
try{
ip = Integer.parseInt(input1);
}catch(NumberFormatException e){
System.out.println("not a number");
}
您是否嘗試過尋找爲電子商務的堆棧跟蹤?例外通常包含非常有用的信息。 –
@Eran 謝謝,它的工作對我來說..! –
見https://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html#MAX_VALUE。 MAX_VALUE = 2_147_483_647 –