From 84efe9398bf6605c0ffba594d2cbd15682dc8eb0 Mon Sep 17 00:00:00 2001 From: m_ozawa <26-m-ozawa-swnet@it-college.co.jp> Date: Wed, 9 Sep 2026 15:26:34 +0900 Subject: [PATCH] =?UTF-8?q?2=E6=97=A5=E7=9B=AE=E3=80=80=E6=AE=B5=E9=9A=8E?= =?UTF-8?q?=EF=BC=94=E3=80=80=E5=B0=8F=E6=BE=A4=20StringCheck=E3=81=8C?= =?UTF-8?q?=E6=AE=B5=E9=9A=8E=EF=BC=93=E3=81=BE=E3=81=A7=E3=81=A7=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E3=81=97=E3=81=A6=E3=81=84=E3=81=9F=E3=82=AF=E3=83=A9?= =?UTF-8?q?=E3=82=B9=E3=81=A7=E3=80=81StringCheckRef=E3=81=8C=E6=AE=B5?= =?UTF-8?q?=E9=9A=8E=EF=BC=94=E3=81=A7=E6=9B=B8=E3=81=8D=E7=9B=B4=E3=81=97?= =?UTF-8?q?=E3=81=9F=E3=82=82=E3=81=AE=E3=81=A7=E3=81=99=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- StringCheck/src/stringCheck/StringCheck.java | 11 ++---- .../src/stringCheck/StringCheckRef.java | 39 +++++++++++++++++++ 2 files changed, 42 insertions(+), 8 deletions(-) create mode 100644 StringCheck/src/stringCheck/StringCheckRef.java diff --git a/StringCheck/src/stringCheck/StringCheck.java b/StringCheck/src/stringCheck/StringCheck.java index 4af15c0..09edfbd 100644 --- a/StringCheck/src/stringCheck/StringCheck.java +++ b/StringCheck/src/stringCheck/StringCheck.java @@ -10,9 +10,7 @@ public class StringCheck { comment[2] = "投稿文が長すぎます"; comment[3] = "\"↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓\""; -// for (String testComm : comment) { -// System.out.println(testComm); -// } + while (true) { System.out.println(comment[0]); @@ -20,12 +18,9 @@ public class StringCheck { String text = scanner.nextLine(); String str = text.strip(); -// System.out.println(str.length() == 0); -// System.out.println(str.length() > 140); -// -// System.out.println(140 - str.length()); - if(str.length() < 1) { + + if(str.length() == 0) { System.out.println("何も入力されていません"); continue; }else if(str.length() > 140){ diff --git a/StringCheck/src/stringCheck/StringCheckRef.java b/StringCheck/src/stringCheck/StringCheckRef.java new file mode 100644 index 0000000..cb87f69 --- /dev/null +++ b/StringCheck/src/stringCheck/StringCheckRef.java @@ -0,0 +1,39 @@ +package stringCheck; + +import java.util.Scanner; + +public class StringCheckRef { + public static void main(String[] args) { + String[] comment = new String[4]; + comment[0] = "いまなにしてる?"; + comment[1] = "何も入力されていません"; + comment[2] = "投稿文が長すぎます"; + comment[3] = "\"↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓\""; + + + + while (true) { + System.out.println(comment[0]); + Scanner scanner = new Scanner(System.in); + String text = scanner.nextLine(); + String str = text.strip(); + + + + if((0