- public int length ()
返回此字符串的长度。
- public boolean equals(String s)
比较两个字符串内容是否相同、区分大小写
- public boolean equalsIgnoreCase (String anotherString)
将此字符串与指定对象进行比较,忽略大小写。
- public char charAt (int index)
返回指定索引处的char值。
- public int indexOf (String str)
返回指定子字符串第一次出现在该字符串内的索引。
- public String substring (int beginIndex)
返回一个子字符串,从beginIndex开始截取字符串到字符串结尾。
- boolean isEmpty()
判断字符串是否为空(长度为0返回true,不为0返回false)
- boolean contains(CharSequence s)
判断字符串中是否包含给定的字符串(这里是区分大小写的)
- boolean startsWith(String prefix)
判断字符串是否以 给定的字符串 开头。
- boolean endsWith(String suffix)
判断字符串是否以 给定的字符串 结尾。
- String toLowerCase()
把字母都转成其对应的小写形式
- String toUpperCase()
把字母都转成其对应的大写形式
- String replace(char oldChar, charnewChar)
用新内容替代旧内容,返回新的字符串
- char[] toCharArray()
将此字符串转换为一个新的字符数组
- byte[] getBytes()
把字符串转换为字节数组(它会去查ASCALL码表)
- String trim()
移除首尾空格(只能去掉首尾的空格,不能去掉中间的)