我正在编写一个将字符串中给定的数字转换为整数的代码。但是它给出超过9位数字的数字格式例外。有没有其他的方式来做到这一点。将字符串转换为整数时获取数字格式异常
public class StringToInt {
public static void main(String args[])
{
try
{
long test =Integer.valueOf("9007199254");
System.out.println("num :"+test);
}catch(NumberFormatException e)
{
System.out.println("Error..."+e.toString());
}
}
}
尝试用'long' –
长也给出了同样的异常 – parimal
尝试'Long.valueOf'不'整数' –