forked from AndrewProgramming/JavaTutorialCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringDemo4.java
More file actions
33 lines (24 loc) · 854 Bytes
/
StringDemo4.java
File metadata and controls
33 lines (24 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package character;
public class StringDemo4 {
public static void main(String[] args) {
String s1 = "Welcome to Java";
String s2 = "Welcome to Java";
String s3 = "Welcome to C++";
System.out.println(s1.equals(s2)); // true
System.out.println(s1.equals(s3)); // false
String s4 = "abc";
String s5 = "abg";
System.out.println(s4.compareTo(s5));
System.out.println('c' - 'g');
String s6 = "ABC";
System.out.println(s4.equalsIgnoreCase(s6));
System.out.println(s4.compareToIgnoreCase(s6));
System.out.println(s1.startsWith("We"));
System.out.println(s1.startsWith("we"));
System.out.println(s1.endsWith("va"));
System.out.println(s1.endsWith("v"));
System.out.println(s1.endsWith("Va"));
System.out.println(s1.contains("to"));
System.out.println(s1.contains("To"));
}
}