The method is as follows:
Public String substring (int beginindex, int endindex)
The first int is the starting index, corresponding to the starting position in the string number,
The second is the cutoff index position, corresponding to the end position in string
1, obtained the length of the string: Endindex-beginindex;
2, starting from the Beginindex, to the end of Endindex, starting from 0, which does not include endindex position characters
Such as:
"Hamburger". Substring (4, 8) returns "Urge"
"smiles". Substring (1, 5) returns "Mile"
Take the second three substrings of a string a length greater than or equal to 3, just a.substring (A.length () -3, A.length ());
The specific instructions in the manual are as follows:
Substring
Public String substring (int beginindex, int endindex)
Returns a new string, is a substring of this string. The substring begins at the specified Beginindex and extends to the character at index EndIndex-1. Thus the length of the substring is endindex-beginindex.
Examples:
"Hamburger". Substring (4, 8) returns "Urge"
"Smiles". Substring (1, 5) returns "Mile"
Parameters:
Beginindex-the beginning index, inclusive.
Endindex-the ending index, exclusive.
Returns:
The specified substring.
Throws:
Indexoutofboundsexception-if the beginindex is negative, or endindex be larger than the length of this String object, or Beginindex is larger than endindex
The above is a small series for everyone to talk about Java String substring () method of the whole content, I hope to help you, a lot of support cloud Habitat Community ~