package ch07_03;
public class StringTest {
	public static void main(String[] args) {
		String s1 = "abcdefg";
		System.out.println("字符串的长度："+s1.length());
		System.out.println("获取串4位置的字符："+s1.charAt(4));
		System.out.println("串转换为大写字母："+s1.toUpperCase());
		System.out.println("取从位置2开始到尾的子串："+s1.substring(2));
		System.out.println("取从1开始到结束位置5前的子串："+s1.substring(1, 5));
		System.out.println("获取子串de的开始位置："+s1.indexOf("de"));
		System.out.println("获取子串xyz的开始位置："+s1.indexOf("xyz"));
		System.out.println("判断字符串是否以ab为前缀"+s1.startsWith("ab"));
		System.out.println("比较两串相同吗："+s1.compareTo("bbb"));
		String s2 = "张三;李四;王五;赵六";
		String[] s3 = s2.split(";");
		System.out.println("张三;李四;王五;赵六，按；拆分成字符串数组：");
		for (String s : s3) {
			System.out.println(s);
		}
	}
}