public static void main(String[] args) {
String str = new String("ABCDEFG");
// 1: char charAt(int index) 返回指定index处的char值
char a = str.charAt(0);
// System.out.println(a);
// 2: String concat(String str)将指定的字符串str连接到当前字符串的末尾,并返回此新字符串对象
str.concat("H");
// System.out.println(str);
// 3: boolean contains(CharSequence s)此字符串对象是否包含指定的字符序列(一般可以认
// 为是字符串)
boolean bool = str.contains("AB");
// System.out.println(bool);
// 4: boolean startsWith(String prefix)此字符串是否以指定的前缀开头
boolean bool2 = str.startsWith("AB");
// System.out.println(bool2);
// 5: boolean endsWith(String suffx) 此字符串是否以指定的后缀结尾
boolean bool3 = str.endsWith("AB");
// System.out.println(bool3);
// 6: boolean equals(Object anObject)对比此字符串对象与指定对象的内容进行比对
boolean bool4 = str.equals("abcdefgh");
// System.out.println(bool4);
// 7: boolean equalslgnoreCase(String anotherString)对比此字符串对象与指定内容进行忽略
// 大小写的比对
boolean bool5 = str.equalsIgnoreCase("abcdefgh");
// System.out.println(bool5);
// 8: int indexOf(int ch)返回指定字符在字符串对象中首次出现的索引
int index = str.indexOf(1);
// System.out.println(index);
// 9: int indexOf(String str) 返回指定字符串在字符串对象中首次出现的索引
int index2 = str.indexOf("C");
// System.out.println(index2);
// 10: int lastIndexOf(int ch)返回指定字符在字符串对象中最后一次出现的索引
int index3 = str.lastIndexOf(3);
// System.out.println(index3);
// 11: int lastIndexOf(String str)返回指定字符串在字符串对象中最后- -次出现的索引
int index4 = str.lastIndexOf("D");
// System.out.println(index4);
// int length()返回字符串的长度
int length = str.length();
// System.out.println(length);
}
}