public class TestString {
public static void main(String[] args) {
String s1 = new String("abc");
String s2 = "abc";
String s3 = "ABC";
String s4 = "aadbbddedf";
String s5 = "一二三四五六";
String s6 = "abcdefg";
System.out.println(s2.length()); //获取当前字符串的长度
System.out.println(s2.toUpperCase());//将当前字符串转换为大写
System.out.println(s3.toLowerCase());//将当前字符串转换为小写
System.out.println(s4.charAt(2));//获取指定索引位子上的字符
System.out.println(s4.indexOf("d"));//返回指定字符串在当前字符串中第一次出现位置 如果没有查找成功则返回-1
System.out.println(s4.lastIndexOf("d"));/返回指定字符串在当前字符串中最后一次出现位置 如果没有查找成功则返回-1
System.out.println(s5.replaceAll("一","五"));//替换
System.out.println(s6.substring(2));//将当前字符串从指定位置进行截取
System.out.println(s6.substring(3, 5));
}
}