diff --git "a/42 \345\270\270\351\223\255\350\277\234/20230512 Java\344\275\234\344\270\232.md" "b/42 \345\270\270\351\223\255\350\277\234/20230512 Java\344\275\234\344\270\232.md" new file mode 100644 index 0000000000000000000000000000000000000000..2c6d36d80939e234de424b2dbb020cec8b449814 --- /dev/null +++ "b/42 \345\270\270\351\223\255\350\277\234/20230512 Java\344\275\234\344\270\232.md" @@ -0,0 +1,25 @@ +```java +import java.util.Scanner; + +public class Test01 { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + while (true) { + System.out.println("请输入两个的整数,求两个数的和"); + try { + System.out.println("请输入第一个整数:"); + int num1 = sc.nextInt(); + System.out.println("请输入第二个整数:"); + int num2 = sc.nextInt(); + System.out.println("他们的和为:" + (num1 + num2)); + break; + } catch (Exception e) { + System.out.println("输入的整数有误,请重新输入"); + sc.next(); + } + } + } +} + +``` +