您好,请问运行时,输入1.0,为什么会失败呢,让重新输入,为什么1.0不能转换为整数呢?
```java
import java.util.Scanner;
public class TryCatchExercise12 {
public static void main(String[] args) {
String s = null;
int i = 0;
Scanner scanner = new Scanner(System.in);
System.out.println("请输入一个整数:");
do {
try {
s = scanner.next();
i = Integer.parseInt(s);
} catch (Exception e) {
System.out.println(e.getMessage());
System.out.println("again");
}
} while (i == 0);
System.out.println(i);
}
}
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/81ab342da46b42a0a96f5c995c58768e.png "#left")