Integer.valueof(string)字符串转Integer 异常
来源:互联网 发布:淘宝海外买手 编辑:程序博客网 时间:2024/05/02 01:33
目前遇到过两种情况会报错:
1 数字过大 ,异常如下:
Exception in thread "main" java.lang.NumberFormatException: For input string: "2300000000"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.valueOf(Unknown Source)
at com.he.liangliang.App.main(App.java:12)
2 非数字
Exception in thread "main" java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.valueOf(Unknown Source)
at com.he.liangliang.App.main(App.java:12)
解决办法:1 在已知数字大小的情况下可以使用Integer.valueof(string)字符串转Integer ,适当情况可选long,decimal等类型
2 可以使用正则表达式判断是否为数字格式
- Integer.valueof(string)字符串转Integer 异常
- 66、Integer.valueof(String)
- Integer.valueOf(String) 之困惑
- Integer.valueOf(String) 方法出错
- Integer.valueOf(String)方法字符串转整型- 你肯定不知道的疑惑!
- String.valueOf Long.valueOf Integer.valueOf 源码分析 缓存
- Integer.valueOf()
- Integer valueOf
- Integer valueOf
- Integer.valueOf()
- 【转】Integer.valueof ,Integer.parseInt的区别
- Integer.valueof() Integer.parseInt()
- Integer.valueof() Integer.parseInt()
- Integer.valueof Integer.parseOf
- Integer.valueof(String s)与Integer.parseInt(String s)区别
- Integer.parseInt(String)与Integer.valueOf(String)的区别
- Integer.valueOf(String s)与Integer.parseInt(String s)区别
- java中Integer.parseInt(String)与Integer.valueOf(String)区别
- Ubuntu16.04搭建bugzilla缺陷管理系统
- 使TableviewCell排序手势占满cell条
- 浅谈jquery.fn.extend与jquery.extend区别
- Centos 6.5 Zabiix 配置Mysql服务
- shuqian
- Integer.valueof(string)字符串转Integer 异常
- ArcGIS制图表达Representation-制图表达原理
- 混合编程系列
- redis 个人理解和常用命令以及应用场景
- mysql主从同步延迟分析
- Filter(过滤器)常见应用
- poj 1300 欧拉回路判定方法
- 使用 Auto Layout 之后什么时候才能获得正确的 frame?
- Lucene-IKAnalyzer使用