Here's how:
Public String substring (int beginindex, int endIndex) The first int is the starting index, corresponding to the start position in the string number, and the second is the cutoff index position, corresponding to the end position in string 1, The string length obtained is: endindex-beginindex;2, starting from Beginindex, to the end of the EndIndex, starting from 0, which does not include the endIndex position of the word such as: "Hamburger". Substring (4, 8 ) returns "Urge" "smiles". Substring (1, 5) returns "Mile" takes the first three substrings of string A with a length greater than or equal to 3, just a.substring (A.length ()-3, A.length ()) The; manual is specified as follows: substringpublic 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 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 is larger thThe length of this String object, or beginindex is larger than EndIndex.
Substring () method in a string of Java