数组部分
先创建两个String类型的数组
String arr1 = new String ("abcdef");
String arr2 = new String("ghijkl");
//也可以直接写
String arr1 = "abcdef";
String arr2 = "ghijkl";
第一部分包括
charAt() codePointAt() codePointBefore() codePointCount()
//角标索引操作方法
concat() contains() contentEqauls()
System.out.println(arr1.charAt(1));// b
// 返回 char指定索引处的值。
System.out.println(arr1.codePointAt(2));// c
System.out.println((char) arr1.codePointAt(2));// 99
// 返回指定索引处的字符(Unicode代码点)。 ASCII码,强转char型才显示字符
System.out.println(arr1.codePointBefore(3));// c
// 返回指定索引紧挨着前一个的字符(Unicode代码点)。 //结果与上面的相同
System.out.println(arr1.codePointCount(0, 6));// 6 这个功能我暂时不知道有什么用
// 索引0 ~ 6-1 之间一共有多少个字符,右边一定减一。写7会报错空指针
System.out.println(new String(arr1.concat(arr2)));// abcdefghijkl
// 将指定的字符串连接到该字符串的末尾。
System.out.println(arr1.contains("abc"));// true
System.out.println(arr1.contains("a c"));// false
// 当且仅当此字符串包含指定的char值序列时才返回true。
System.out.println(arr1.contentEquals("abcdef"));//true
//一模一样返回true 多一个少一个错一个都是false
第二部分包括
toCharArray() copyValueOf()
toCharArrya()是把String转换为char数组
copyValueOf()是把char数组转换为String,( )中不能加String类型直接copy
char[] C1;
C1=arr1.toCharArray();//①把arr1拆成char[]数组
String arr3 = new String().copyValueOf(C1);
//②把char[]数组copyValueOf成String类型
System.out.println(arr3);//abcdef
第三部分包括
compareTo() compareToIgnoreCase()