diff --git "a/52 \347\216\213\345\217\221\346\247\220/20230510.md" "b/52 \347\216\213\345\217\221\346\247\220/20230510.md" new file mode 100644 index 0000000000000000000000000000000000000000..034edfdcff7b3ced08d688de9b0e03570d005c27 --- /dev/null +++ "b/52 \347\216\213\345\217\221\346\247\220/20230510.md" @@ -0,0 +1,27 @@ +```java +import java.util.Scanner; + +public class Test01 { + public static void main(String[] args) { + int a, b; + Scanner sc = new Scanner(System.in); + while (true) { + System.out.println("输入2个数"); + try { + a = sc.nextInt(); + b = sc.nextInt(); + System.out.println(sum(a, b)); + break; + } catch (Exception e) { + System.out.println("输入错误,重新输入"); + sc.next(); + } + } + } + + private static int sum(int a, int b) { + return a + b; + } +} +``` +