3段階サンプルコードにて完成

This commit is contained in:
m-endo
2026-09-09 15:12:23 +09:00
parent 62eb5f9305
commit 087422fc28

View File

@@ -1,20 +1,32 @@
package lesson1;
import java.util.Scanner;
public class StringCheck {
public static void main(String[] args) {
String[] comment = new String[4];
comment[0] = "いまなにしてる?";
comment[1] = "何も入力されていません";
comment[2] = "投稿文が長すぎます";
comment[3] = "↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓";
String[] str = new String[4]; //
System.out.println(comment[0]);
Scanner scanner = new Scanner(System.in);
String text = scanner.next();
String str = text.strip();
System.out.println("\n" + comment[3]);
System.out.println(str);
str[0] = "いまなにしてる?";
str[1] = "何も入力されていません";
str[2] = "投稿文が長すぎます";
str[3] = "↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓";
boolean isEmpty = str.isEmpty();
System.out.println(isEmpty);
String[] line = new String[4];
System.out.println(line);
int strLength = str.length();
System.out.println(strLength + "文字");
String line1 = "  今日は晴れ  ";
System.out.println(line1.trim());
boolean isRange = strLength > 140;
System.out.println(isRange);
System.out.println(140 - str.length());
}
}