3段階サンプルコードにて完成
This commit is contained in:
@@ -1,20 +1,32 @@
|
|||||||
package lesson1;
|
package lesson1;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class StringCheck {
|
public class StringCheck {
|
||||||
public static void main(String[] args) {
|
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] = "いまなにしてる?";
|
boolean isEmpty = str.isEmpty();
|
||||||
str[1] = "何も入力されていません";
|
System.out.println(isEmpty);
|
||||||
str[2] = "投稿文が長すぎます";
|
|
||||||
str[3] = "↓↓↓↓↓↓ 投稿されました ↓↓↓↓↓↓";
|
|
||||||
|
|
||||||
String[] line = new String[4];
|
int strLength = str.length();
|
||||||
System.out.println(line);
|
System.out.println(strLength + "文字");
|
||||||
|
|
||||||
String line1 = " 今日は晴れ ";
|
boolean isRange = strLength > 140;
|
||||||
System.out.println(line1.trim());
|
System.out.println(isRange);
|
||||||
|
|
||||||
|
System.out.println(140 - str.length());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user