String s1="hello lxx";
String s2=new String("fff df");
System.out.println(s1.length());
System.out.println(s1.substring(0, 2));
System.out.println(s1.equals(s2));
System.out.println(s1.charAt(3));
System.out.println(s1.replace("o","r"));
System.out.println(s1.indexOf("l"));
StringBuilder s3=new StringBuilder("hello nihao");
System.out.println(s3.append("a"));
// 打印s3的容量capacity()
System.out.println(s3.capacity());
//在2的位置插入b字符串
System.out.println(s3.insert(2, "b"));
System.out.println(s3.delete(2, 3));
//reverse反转
System.out.println(s3.reverse());
运行结果
9
he
false
l
hellr lxx
2
hello nihaoa
27
hebllo nihaoa
hello nihaoa
aoahin olleh