-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStrings.java
More file actions
16 lines (16 loc) · 913 Bytes
/
Strings.java
File metadata and controls
16 lines (16 loc) · 913 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public class Strings {
public static void main(String[] args) {
String message = "Hello " + "World" + "!!";
message = message.toUpperCase();
System.out.println(message);
System.out.println(message.endsWith("!!"));
System.out.println(message.length());
System.out.println(message.indexOf("W")); // -1 if doesn't include
System.out.println(message.replace("!", "$")); //does not modify origian string
System.out.println(message.trim()); // removes white spaces from start/end of the string
System.out.println("Hello \"Max\""); // Escape sequence for ""
System.out.println("C:\\Windows\\System32\\..."); // Escape sequence for ""
System.out.println("C:\nWindows\\System32\\..."); // Escape sequence for "" - breaks line \n
System.out.println("C:\tWindows\\System32\\..."); // Escape sequence for "" - tab \t
}
}