我想解析一个字符串为int值。但是我得到一个NumberFormat异常。我写了下面的代码:在BlackBerry中获取NumberFormat例外
Logger.out("Myprof", "Contact "+strContact);
try{
i = Integer.parseInt(strContact.trim());
Logger.out("Myprof", "Contact8686866 "+i);
}
catch(Exception e)
{
Logger.out("Myprof", "exce "+e.toString());
}
现在,当我路过象下面这样:
i = Integer.parseInt("11223344");
我得到了我价值11223344.
我哪里做错了?请帮忙。
它是可能的'strContact'包含非数字字符或为空。在尝试解析它之前输出变量。完整的堆栈跟踪告诉你什么? – Reimeus
strContact是一个字符串。它在这一行给出适当的值:Logger.out(“Myprof”,“Contact”+ strContact); –
它在这一行中给我这个结果:Myprof: - :contact 9875566521 –