40 lines
895 B
Java
40 lines
895 B
Java
package stringCheck;
|
|
|
|
import java.util.Scanner;
|
|
|
|
public class StringCheckRef {
|
|
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();
|
|
|
|
|
|
|
|
if((0<str.length()) && (str.length()<=140)){
|
|
System.out.println("\n" + comment[3]);
|
|
System.out.println(str);
|
|
break;
|
|
}else if(str.length() == 0) {
|
|
System.out.println("何も入力されていません");
|
|
continue;
|
|
}else {
|
|
System.out.println("投稿文が長すぎます");
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|