package baseClass7;

public class StringBuilderClass {
public static void main(String[] args) {
String s1 = "chaoqiqiang.chaoqq.cqq";
String s2 = ".chaoqq";// 应为后缀全部
String s3 = ".cqq";
String s4 = "q";
String s7 = s2.replace(s2, "qq");// s2.replace(oldChar,// newChar)可为字符也可为字符串;
System.out.println(s1.endsWith(s2));//false
System.out.println(s1.endsWith(s3));//true
System.out.println(s1.endsWith(s4));//true
System.out.println(s1.endsWith(s7));//true
System.out.println(s1.indexOf(s4, 5));//输出6 s1.indexOf(ch,// fromIndex)从fromIndex开始正向读取
System.out.println(s1.substring(4, 13));//qiqiang.c 截取索引[4,13)
System.out.println(s1.lastIndexOf('q', 15));//输出6 默认为s1的长度,从fromIndex开始反向读取
System.out.println("----------------------------");
char[] c1 = { 'I', ' ', 'L', 'o', 'v', 'e', ' ', 'J', 'a', 'v', 'a',
'w', 'e', 'b' };
String s = "ejbc";
s.getChars(0, 3, c1, 7);// [0,3)
System.out.println(c1);//I Love ejbaweb
s.getChars(1, 4, c1, 7);// {1,2,3}即[1,4)
System.out.println(c1);//I Love jbcaweb
System.out.println("--------------------------------------");
String s5 = new String("巴西足球队击败德国足球队");
char[] c = new char[s5.length()];//12
System.out.println(s5.length());
s5.getChars(7, 12, c, 0);
System.out.println(c);//德国足球队
s5.getChars(5, 7, c, 5);
System.out.println(c);//德国足球队击败
s5.getChars(0, 5, c, 7);
System.out.println(c);//德国足球队击败巴西足球队
System.out.println("------------------------------------");
String s6 = "日本想打败中国是不可能的";
char[] c2 = new char[12];// s6.length()更恰当;
s6.getChars(5, 7, c2, 0);
s6.getChars(3, 5, c2, 2);
s6.getChars(0, 2, c2, 4);
s6.getChars(7, 8, c2, 6);
s6.getChars(9, s6.length(), c2, 7);
System.out.println(c2);

}
}