From fd5d0ed2b61e75cd7578228a36ef5164041267f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?22=20=E5=91=A8=E5=85=83=E4=BF=8A=E4=B8=B4?= <1654759188@qq.com> Date: Fri, 12 May 2023 23:43:53 +0800 Subject: [PATCH] java --- .../20230512 \345\274\202\345\270\270.md" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "22 \345\221\250\345\205\203\344\277\212\344\270\264/20230512 \345\274\202\345\270\270.md" diff --git "a/22 \345\221\250\345\205\203\344\277\212\344\270\264/20230512 \345\274\202\345\270\270.md" "b/22 \345\221\250\345\205\203\344\277\212\344\270\264/20230512 \345\274\202\345\270\270.md" new file mode 100644 index 0000000..cf37d5e --- /dev/null +++ "b/22 \345\221\250\345\205\203\344\277\212\344\270\264/20230512 \345\274\202\345\270\270.md" @@ -0,0 +1,27 @@ +```java + +import java.util.Scanner; + +public class D1 { + public static void main(String[] args) { + while (true) { + try { + Scanner sc = new Scanner(System.in); + System.out.println("输入第一个整数"); + int a = sc.nextInt(); + System.out.println("输入第二个整数"); + int b = sc.nextInt(); + ab(a, b); + System.out.println(a + b); + break; + } catch (Exception e) { + System.out.println("输入错误"); + + } + } + } + private static int ab(int a,int b) { + return a+b; + } +} +``` \ No newline at end of file -- Gitee