1public class StringDemo
 2{
 3 public static void main(String[] args)
 4 {
 5  String myName="G. Leeman";
 6  int length="涂静静".length();
 7  System.out.println("长度1:"+myName.length());
 8  System.out.println("长度2:"+length);
 9  String name1="programming in java";
10  String name2="Programming in Java";
11  System.out.println("比较1:"+name1.equals(name2));
12  System.out.println("比较2:"+name2.equalsIgnoreCase(name2));
13  System.out.println("比较3:"+name2.compareTo("Progam"));
14  System.out.println("字符1:"+name1.charAt(4));
15  System.out.println("字符2:"+name1.indexOf('a'));
16  System.out.println("字符3:"+name2.lastIndexOf('a'));
17  String subname="in";
18  System.out.println("子串1:"+name1.substring(3,10));
19  System.out.println("子串2:"+"abc".concat("123"));
20  System.out.println("子串3:"+name2.startsWith("Pro"));
21  System.out.println("子串4:"+name2.endsWith("in Java"));
22  System.out.println("子串5:"+name1.indexOf(subname));
23  System.out.println("子串6:"+name1.lastIndexOf(subname));
24  System.out.println("小写:"+name2.toLowerCase());
25  System.out.println("大写:"+name2.toUpperCase());
26  System.out.println("替换:"+name1.replace('a','A'));
27 }

28}