String
boolean startsWith (String prefix)
Tests if this string starts with the specified prefix.
此字符串是否以指定的前缀开始测试。
String substring (int beginIndex, int endIndex)
Returns a new string that is a substring of this string. The substring begins at the specified beginIndex
and extends to the character at indexendIndex - 1
Thus the length of the substring is endIndex-beginIndex
返回一个新字符串,它是此字符串的一个子。该子字符串从指定的beginIndex,并扩展到索引endIndex的字符 - 1。这样子串的长度为endIndex的-beginIndex。
例子:
"hamburger".substring(4, 8) returns "urge"
"smiles".substring(1, 5) returns "mile"
String substring (int beginIndex)
Returns a new string that is a substring of this string. The substring begins with the character at the specified index and extends to the end of this string.
返回一个新字符串,它是此字符串的一个子。然后子始于指定索引处的字符,一直到此字符串的结尾。
Examples:
"unhappy".substring(2) returns "happy"
"Harbison".substring(3) returns "bison"
"emptiness".substring(9) returns "" (an empty string)