java.lang.NumberFormatException: For input string: ""

查看:225
本文介绍了java.lang.NumberFormatException: For input string: ""的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

    goalData.add(new Profit(tempSaveData.get(0), tempSaveData.get(1), tempSaveData.get(2) == "" ? 0 : Integer.parseInt(tempSaveData.get(2)), tempSaveData.get(3) == "" ? 0 : Integer.parseInt(tempSaveData.get(3)))

如上代码,在2和3的字段中,是为integer的。但是导入的数据是null,于是,我把它设置为,然后让三目判断,怎么还是提示这个错误呢?

tempSaveData是String集合,List<String>,我把没有数据的都设置为""报错在这个数组中,然后放进上面的对象中,
tempSaveData.get(2)这些都是String类型的

=====================================================

已经解决:用equals

解决方案

"".equals(tempSaveData.get(2))

这篇关于java.lang.NumberFormatException: For input string: &quot;&quot;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆