String
class String{
public static void main(String[] args) {
String name;
name = "jackma";
name = "tomlei";
name = name + "ssss";
System.out.println(name);
String s = new String("this is String");
String s1 = new String("this is String");
String n = "HelloWorld";
int index = n.indexOf("H");
System.out.println(index);
String sub1=n.substring(5)
System.out.println(sub1);
String sub2 =n.substring(0, 5);;
System.out.println(sub2);
String w1=" sss ";
w1=w1.trim();
System.out.println(w1);
}
}
StringBuffer
public class StringBufferTest01 {
public static void main(String[] args) {
StringBuffer sb = new StringBuffer();
sb.append(true);
sb.append("abc");
System.out.println(sb);
sb.deleteCharAt(5);
System.out.println(sb);
sb.delete(4, 6);
System.out.println(sb);
sb.insert(2, "abc");
System.out.println(sb);
sb.reverse();
System.out.println(sb);
sb.setCharAt(0,'E');
System.out.println(sb);
}
}
}