java.lang.String常用方法
- char charAt(int index)
- 返回指定索引处的char值
- int compareTo(String anotherString)
- 按字典顺序比较两个字符串
- int compareToIgnoreCase(String str)
- 按字典顺序比较两个字符串,不考虑大小写
- String concat(String str)
- 将指定字符串连接到此字符串的结尾
- boolean contains(CharSequence cs)
- 当且仅当此字符串包含指定的char值序列时,返回true
- static String copyValurOf(char[] data)
- 返回指定数组中表示该字符序列的String
- boolean endsWith(String suffix)
- 测试此字符串是否以指定的后缀结束
- boolean equals(Object anObj)
- 将此字符串与指定的对象比较
- boolean equalsIgnoreCase(String oString)
- 将此String对象与另一个String比较,不考虑大小写。
- int length()
- 返回此字符串的长度
- boolean matches(String regex)
- 告知此字符串是否匹配给定的正则表达式
- String replace(char oldChar, char newChar)
- newChar替换此字符串所有oldChar
- String replaceAll(String regex, String replacement)
- 使用给定的replacement字符串替换此字符串所有匹配的给定的正则表达式的子字符串
- String[] split(String regex)
- 根据给定的正则表达式匹配拆分此字符串
- boolean startsWith(String prefix)
- 测试此字符串是否以指定的前缀开始
- startWith(String prefix, int toffset)
- 测试此字符串从指定索引开始的子字符串是否以指定前缀开始
- String substring(int beginIndex)
- 返回一个新字符串,从位置beginIndex开始。
- substring(int beginIndex, int endIndex)
- 返回一个新字符串,截取从位置beginIndex开始到endIndex结束
- String toLowerCase()
- 转小写
- toUpperCase()
- 转大写
- String trim()
- 返回字符串的副本,忽略前导空白和尾部空白。
- String valueOf(Object object)
- 其他类型转为字符串类型

更多精彩