有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

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) 个答案