段階1です。

This commit is contained in:
2026-09-09 16:02:22 +09:00
parent d71c368610
commit ffa39401df

View File

@@ -3,23 +3,35 @@ package 短文投稿プログラム;
import java.util.Scanner; import java.util.Scanner;
public class StringCheck { public class StringCheck {
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();
System.out.println("\n" + comment[3]);
System.out.println(str);
public static void main(String[] args) { boolean isEmpty = str.isEmpty();
// TODO 自動生成されたメソッド・スタブ System.out.println(isEmpty);
String[]tango = new String[4];
//初期化
tango[0]="いまなにしてる?";
tango[1]="何も入力されていません";
tango[2]="投稿文が長すぎます";
tango[3]="↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓";
Scanner sc = new Scanner(System.in); int strLength = str.length();
//標準入力から1行読み取る方法 System.out.println(strLength + "文字");
String str = "  今日は晴れ  ";
// 全角スペースを含む空白の除去
System.out.println("Before: [" + str + "]");
System.out.println("After: [" + str.strip() + "]");
}
boolean isRange = strLength > 140;
System.out.println(isRange);
System.out.println(140 - str.length());
for (String commentt: comment)
System.out.println(commentt);
}
}
} }