From d16b47bc60e1b1032c9d67ffd682434ded1724f1 Mon Sep 17 00:00:00 2001 From: "h.hein" <26-h-kyaw-sakuracommunication@it-college.co.jp> Date: Wed, 9 Sep 2026 15:19:17 +0900 Subject: [PATCH] Day2 stept 4 --- Exercises/src/Day2/StringCheck.java | 61 +++++++++++++---------------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/Exercises/src/Day2/StringCheck.java b/Exercises/src/Day2/StringCheck.java index c4f2df9..88c2413 100644 --- a/Exercises/src/Day2/StringCheck.java +++ b/Exercises/src/Day2/StringCheck.java @@ -12,42 +12,37 @@ public class StringCheck { //int maxLength = 140; // 段階1: 無限ループ化 - while (true) { - System.out.println(messages[0]); - str = scan.nextLine(); - //str = scan.nextLine().trim(); - str = str.replaceAll("[\\s ]", ""); - //String str1 = str.replaceAll("[  ]", ""); + while (true) { + System.out.println(messages[0]); + str = scan.nextLine(); + //str = scan.nextLine().trim(); + str = str.replaceAll("[\\s ]", ""); + //String str1 = str.replaceAll("[  ]", ""); - //System.out.println("あなたの入力は: [" + str + "]"); - - - //2段階のif - boolean isEmpty = str.isEmpty(); - boolean isTooLong = str.length() > 140; - - if(isEmpty) { - System.out.println(messages[1]); - continue; - } + //System.out.println("あなたの入力は: [" + str + "]"); + + //2段階のif + boolean isEmpty = str.isEmpty(); + boolean isTooLong = str.length() > 140; + + if (isEmpty) { + System.out.println(messages[1]); + continue; + } //(Length check) 140 under - - if (isTooLong) { - System.out.println(messages[2]); - continue; - } - - break; - } - System.out.println(); - System.out.println(messages[3]); - System.out.println(str); - - scan.close(); - + if (isTooLong) { + System.out.println(messages[2]); + continue; + } + break; + } + System.out.println(); + System.out.println(messages[3]); + System.out.println(str); + + scan.close(); -} } - +}