Java:将字符串转换为整数时的NumberFormatException
我想从文本框中检索值并将其转换为整数。我写了下面的代码,但它抛出了一个NumberFormatException
String nop = no_of_people.getText().toString();
System.out.println(nop);
int nop1 = Integer.parseInt(nop);
System.out.println(nop1);
对System.out.println
的第一次调用会打印出数字,但转换为整数会出现异常。我做错了什么
共 (0) 个答案