ash*_*thi 0 java numberformatexception
我面临以下问题:
与临时值相比,我将获得类似或更长的值:
public class NumberFormat {
public static void main(String arg[]){
Integer numValue = null;
String temp="5474151538110135";
numValue=Integer
.parseInt(temp.trim());
System.out.println("--> "+numValue);
}
}
Run Code Online (Sandbox Code Playgroud)
请提供解决方案.
Exception in thread "main" java.lang.NumberFormatException: For input string: "5474151538110135"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:60)
at java.lang.Integer.parseInt(Integer.java:473)
at java.lang.Integer.parseInt(Integer.java:511)
at com.filetransfer.August.NumberFormat.main(NumberFormat.java:10)
Run Code Online (Sandbox Code Playgroud)
5474151538110135大于Integer.MAX_VALUE.使用Long.parseLong相反或BigInteger输入数字可能会显着增长
Long numValue = Long.parseLong(temp.trim());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
123 次 |
| 最近记录: |