方法 | 描述 |
int length() | 返回此字符串的长度 |
int indexof(int ch) | 返回指定字符在此字符串中第一次出现处的索引 |
int indexOf(int ch,int fromIndex) | 此类在字符串中第一次出现指定字符处的索引,从指定的做因开始搜索 |
int lastIndexOf(String str) | 返回指定字符在此字符串中最后一次出现处的索引 |
String concat(String str) | 将指定字符串连接到此字符串的结尾 |
boolean endsWith(String suffix) | 测试此字符串是否以指定的后缀结束 |
String replace(CharSequence target, CharSequence replacement) | 返回一个新的字符串,它是通过用new char替换此字符串出现的所有old char得到的 |
String trim() | 返回字符串的副本,忽略前导空白和尾部空白 |
boolean equals(Object anObject) | 将此字符串与指定的对象比较 |
String[] split(String regex) | 根据给定正则表达式的匹配拆分此字符串 |
String substring(int beginIndex) | 返回一个新的字符串,它是此字符串的一个子字符串 |
JAVA String 常用方法类
于 2023-09-18 14:00:27 首次发布