Files
stringcheck/StringCheck20261008_瓦.java
2026-10-08 16:56:14 +09:00

83 lines
1.5 KiB
Java
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import java.util.Scanner;
public class StringCheck {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
String[] main;
main = new String[4];
main[0] = "いまなにしてる?";
main[1] = "何も入力されていません";
main[2] = "投稿文が長すぎます";
main[3] = "↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓";
for (String text : main) {
System.out.println(text);
}
System.out.println(main[0]);
System.out.println("");
Scanner scanner = new Scanner(System.in);
String str = scanner.nextLine();
str = str.replace(" ","").replace(" ","");
while (true) {
System.out.println("");
System.out.println("");
int length = str.length();
boolean isEmpty = length == 0;
System.out.println("0文字かどうか: " + isEmpty);
boolean inWithinLimit = length <= 140;
System.out.println("140文字以下か?: " + inWithinLimit);
int remaining = 140 - length;
System.out.println("残りの文字数" + remaining);
if (isEmpty == true) {
System.out.println("何も入力されていません");
continue;
}
else if(inWithinLimit = true) {
System.out.println("投稿文が長すぎます");
continue;
}
System.out.println("");
System.out.println(main[3]);
System.out.println(str);
scanner.close();
}
}
}