字符串常用方法
这里是String类支持的常用方法列表:
序号 | 方法描述 |
---|---|
1 | char charAt(int index) |
2 | int compareTo(String anotherString) |
3 | int compareToIgnoreCase(String str) |
4 | String concat(String str) |
5 | boolean endsWith(String suffix) |
6 | boolean equals(Object anObject) |
7 | boolean equalsIgnoreCase(String anotherString) |
8 | int hashCode() |
9 | int indexOf(int ch) |
10 | int indexOf(int ch, int fromIndex) |
11 | int indexOf(String str) |
12 | int indexOf(String str, int fromIndex) |
13 | int lastIndexOf(String str) |
14 | int length() |
15 | String replace(char oldChar, char newChar) |
16 | String replaceAll(String regex, String replacement 用给定的字符串来替换与正则表达式匹配的字符串。 |
17 | String[] split(String regex) |
18 | boolean startsWith(String prefix) |
19 | String substring(int beginIndex) |
20 | String substring(int beginIndex, int endIndex) |
21 | char[] toCharArray() |
22 | String toLowerCase() |
23 | String toUpperCase() |
24 | String trim() |