java.lang.NumberFormatException: Invalid int: ""的解决方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sinat_15411661/article/details/52230059

java.lang.NumberFormatException: Invalid int: ""不能成功转成int类型

错误代码:

 
 
private int allCount;
String temp = null;
allCount = Integer.parseInt(temp);

更改代码(添加try catch使之兼容性增强):
 
 
 
 
 try {
   String temp = null;
   allCount = Integer.parseInt(temp);   
  } catch (Exception e) {    
   allCount = 200;  
  }



 
 
 
 
 
 

猜你喜欢

转载自blog.csdn.net/sinat_15411661/article/details/52230059