测试的字符串为String s1="abc123"
1.isEmpty();判断字符串是否为空
boolean empty = s1.isEmpty();
System.out.println(empty);//false
2.
contains("a");判断字符串中是否包含指定字符
boolean a = s1.contains("a");
System.out.println(a);//true
3.
substring(1);//从指定位置进行分割
substring(1, 2);//从指定范围进行分割
String substring1 = s1.substring(1);//从指定位置进行分割
System.out.println(substring1);//bc123
String substring = s1.substring(1, 2);//从指定范围进行分割
System.out.println(substring);//b
4.
toUpperCase();//大写
toLowerCase();//小写
String s = s1.toUpperCase();//大写
System.out.println(s);//ABC123
String s2 = s.toLowerCase();//小写
System.out.println(s2);//abc123
5.
charAt(1);//指定位置的字符
char c = s1.charAt(1);//指定位置的字符
System.out.println(c);//b
6.
equals("Abc");//字符串比较
equalsIgnoreCase("ABC");//忽略大小写
boolean abc = s1.equals("Abc");//字符串比较
System.out.println(abc);//false
boolean abc1 = s1.equalsIgnoreCase("ABC");//忽略大小写
System.out.println(abc1);//false
7.
concat("abc");//将指定字符连接到结尾
String abc2 = s1.concat("abc");//将指定字符连接到结尾
System.out.println(abc2);//abc123abc
8.
indexOf("lo");//返回字符串在指定子串中的第一次位置,如果没找到,则返回-1
indexOf("l0",2);//从指定位置开始找字符串在指定子串中第一次出现的位置,没有则返回-1
lastIndexOf("lo");//,从后往前找返回字符串在指定子串中的第一次位置,如果没找到,则返回-1
lastIndexOf("l0",2);//从指定位置从后往前开始找字符串在指定子串中第一次出现的位置,没有则返回-1
System.out.println(s1.indexOf("lo"));//-1,返回字符串在指定子串中的第一次位置,如果没找到,则返回-1
System.out.println(s1.indexOf("l0",2));//-1,从指定位置开始找字符串在指定子串中第一次出现的位置,没有则返回-1
System.out.println(s1.lastIndexOf("lo"));//-1,从后往前找返回字符串在指定子串中的第一次位置,如果没找到,则返回-1
System.out.println(s1.lastIndexOf("l0",2));//-1,从指定位置从后往前开始找字符串在指定子串中第一次出现的位置,没有则返回-1
9.
replace("a", "ccc");//将指定位置的字符替换成想要替换的字符
String replace = s1.replace("a", "ccc");//将指定位置的字符替换成想要替换的字符
System.out.println(replace);//cccbc123