練習問題5-1
String str = "Hello, World!";
int length = str.length();
System.out.println(length); // 13
String str = "Hello, World!";
int length = str.length();
System.out.println(length); // 13
String str = "Hello, World!";
String uppercase = str.toUpperCase();
System.out.println(uppercase); // HELLO, WORLD!
String str = "Hello, World!";
String lowercase = str.toLowerCase();
System.out.println(lowercase); // hello, world!
String str = "Hello, World!";
boolean containsHello = str.contains("Hello");
System.out.println(containsHello); // true
String str = "Hello,World!";
String[] parts = str.split(",");
for (String part : parts) {
System.out.println(part);
}
String str = " Hello, World! ";
String trimmed = str.trim();
System.out.println(trimmed); // Hello, World!
String str = "Hello, World!";
String replaced = str.replace("Hello", "Hi");
System.out.println(replaced); // Hi, World!
String str = "Hello, World!";
int index = str.indexOf("World");
System.out.println(index); // 7
String[] words = {"Hello", "World!"};
String joined = String.join(", ", words);
System.out.println(joined); // Hello, World!
String str = "Hello, World!";
String substring = str.substring(7);
System.out.println(substring); // World!