段階1終わりました

This commit is contained in:
2026-09-09 13:25:16 +09:00
parent 22920ecacb
commit 0efa10e7df

View File

@@ -1,8 +1,7 @@
import java.util.Scanner; import java.util.Scanner;
public class StringCheck { public class StringCheck {
public static void main(String[] args){ public static void main(String[] args) {
// 初期化・宣言 // 初期化・宣言
String[] classNames = { String[] classNames = {
@@ -16,36 +15,44 @@ public class StringCheck {
//標準入力から1行分の文字列を読み込む //標準入力から1行分の文字列を読み込む
Scanner scan = new Scanner(System.in); Scanner scan = new Scanner(System.in);
System.out.println(classNames[0]);
String str = scan.nextLine();
//読み込んだ文字列の前後にある空白文字を除去 while(true) {
System.out.println(str.strip());
scan.close(); System.out.println(classNames[0]);
String str = scan.nextLine();
// 文字列の長さを取得 // 文字列の長さを取得
int length = str.length(); int length = str.length();
// 空字判定 // 空字判定
boolean isEmpty = (length == 0); boolean isEmpty = (length == 0);
// 文字数超過判定 // 文字数超過判定
boolean isOverLimit = (length > 140); boolean isOverLimit = (length > 140);
// 残り入力可能文字数 // 残り入力可能文字数
int a = (140 - length); int a = (140 - length);
System.out.println(); System.out.println();
System.out.println(classNames[3]); System.out.println(classNames[3]);
//読み込んだ文字列の前後にある空白文字を除去
System.out.println(str.strip()); System.out.println(str.strip());
}
// for-each練習
// for (String name : classNames) {
// System.out.println(name);
// }
} }
} }