public char charAt(int index)
//charAt() 方法用于返回指定索引处的字符。索引范围为从 0 到 length() - 1。
//返回值
//返回指定索引处的字符。
int compareTo(Object o)
//或
int compareTo(String anotherString)
//compareTo() 方法用于两种方式的比较:
//字符串与对象进行比较。
//按字典顺序比较两个字符串。
//返回值
//如果参数字符串等于此字符串,则返回值 0;
//如果此字符串小于字符串参数,则返回一个小于 0 的值;
//如果此字符串大于字符串参数,则返回一个大于 0 的值。
public int indexOf(int ch):
//返回指定字符在字符串中第一次出现处的索引,如果此字符串中没有这样的字符,则返回 -1。
public int indexOf(int ch, int fromIndex):
//返回指定字符在字符串中第一次出现处的索引,如果此字符串中没有这样的字符,则返回 -1。
int indexOf(String str):
//返回指定字符在字符串中第一次出现处的索引,如果此字符串中没有这样的字符,则返回 -1。
int indexOf(String str, int fromIndex):
//返回指定字符在字符串中第一次出现处的索引,如果此字符串中没有这样的字符,则返回 -1。
//返回值
//指定子字符串在字符串中第一次出现处的索引,从指定的索引开始。
public String[] split(String regex,int limit)
//返回值
//成功则返回替换的字符串,失败则返回原始字符串。
public String substring(int beginIndex)
//或
public String substring(int beginIndex, int endIndex)
//参数
//beginIndex -- 起始索引(包括)。
//endIndex -- 结束索引(不包括)。
//返回值
//子字符串。
public char[] toCharArray()
//返回值
//字符数组。toCharArray() 方法将字符串转换为字符数组。
public String trim()
//返回值
//删除头尾空白符的字符串。
public String replace(char oldChar,char newChar)
//参数
//oldChar -- 原字符。
//newChar -- 新字符。
//返回值
//替换后生成的新字符串。
public byte[] getBytes(String charsetName) throws UnsupportedEncodingException
//或
public byte[] getBytes()
//参数
//charsetName -- 支持的字符集名称。
//返回值
//返回 byte 数组。
//getBytes(String charsetName):使用平台的默认字符集将字符串编码为 byte 序列,并将结果存储到一个新的 byte 数组中。
//getBytes(): 使用平台的默认字符集将字符串编码为 byte 序列,并将结果存储到一个新的 byte 数组中。
参考: