diff --git "a/19\345\275\255\345\213\207\346\226\214/\345\274\202\345\270\270.md" "b/19\345\275\255\345\213\207\346\226\214/\345\274\202\345\270\270.md" new file mode 100644 index 0000000000000000000000000000000000000000..102863b190f80c9a20b368316c1fc12e6fd03dea --- /dev/null +++ "b/19\345\275\255\345\213\207\346\226\214/\345\274\202\345\270\270.md" @@ -0,0 +1,21 @@ +```java +import java.util.Scanner; + +public class ZY1 { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + while (true) { + System.out.println("请输入整数"); + String nm = sc.next(); + + try { + int n1 = Integer.parseInt(nm); + System.out.println("整数的和是" + n1); + break; + } catch (NumberFormatException e) { + System.out.println("只能输入整数,请重新输入"); + } + } + } + } +``` \ No newline at end of file