段階1です。
This commit is contained in:
@@ -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) {
|
public static void main(String[] args) {
|
||||||
// TODO 自動生成されたメソッド・スタブ
|
String[] comment = new String[4];
|
||||||
String[]tango = new String[4];
|
comment[0] = "いまなにしてる?";
|
||||||
//初期化
|
comment[1] = "何も入力されていません";
|
||||||
tango[0]="いまなにしてる?";
|
comment[2] = "投稿文が長すぎます";
|
||||||
tango[1]="何も入力されていません";
|
comment[3] = "↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓";
|
||||||
tango[2]="投稿文が長すぎます";
|
|
||||||
tango[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);
|
||||||
|
|
||||||
Scanner sc = new Scanner(System.in);
|
boolean isEmpty = str.isEmpty();
|
||||||
//標準入力から1行読み取る方法
|
System.out.println(isEmpty);
|
||||||
String str = " 今日は晴れ ";
|
|
||||||
// 全角スペースを含む空白の除去
|
int strLength = str.length();
|
||||||
System.out.println("Before: [" + str + "]");
|
System.out.println(strLength + "文字");
|
||||||
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user