public class TestStringExamples
1: //TestStringExamples.java
2:
3: import java.util.Scanner;
4:
5: public class TestStringExamples
6: {
7: public static void main(String[] args)
8: {
9: //Put test code here ...
10: /*
11: String s = "Hello, ";
12: String t = s.concat("world!");
13: System.out.println(t.length());
14: System.out.println("Hello, world!".length());
15: System.out.println(s);
16:
17: String s1 = "Hello";
18: String s2 = "hello";
19: System.out.println(s1.equals(s2));
20: System.out.println(s1.equalsIgnoreCase(s2));
21:
22: System.out.println("big".compareTo("small"));
23: System.out.println("small".compareTo("big"));
24: System.out.println("abcd".compareTo("abcd"));
25: System.out.println("big".compareTo("Small"));
26:
27: String s = "Hello, world! How low can you go?";
28: System.out.println(s.indexOf("lo"));
29: System.out.println(s.lastIndexOf("lo"));
30:
31: String s = "Hello, world! How low can you go?";
32: System.out.println(s);
33: System.out.println(s.toUpperCase());
34: System.out.println(s.toLowerCase());
35: System.out.println(s);
36:
37: System.out.println("abcdaabcab");
38: System.out.println("abcdaabcab".replace('a', 'z'));
39: System.out.println("abcdaabcab".replace("ab", "xxyyzz"));
40: */
41:
42: String s = "Hello, world! How low can you go?";
43: System.out.println(s.substring(14));
44: System.out.println(s.substring(14, 19));
45: }
46: }
47: