substring (int beginindex)
Returns a new string that is a substring of this string. The substring begins at the specified index at the end of the string.
For example:
"Unhappy". SUBSTRING (2) returns "Happy"
"Harbison". SUBSTRING (3) returns "Bison"
"emptiness". Substring (9) Returns "" (An empty string)
Parameters:Beginindex-Index at the beginning (including).
return:The specified substring.
Thrown:
Indexoutofboundsexception-if beginindex is negative or greater than the length of this String object.
==========================================================================
substring (int beginindex,
int endindex)
Returns a new string that is a substring of this string. The substring starts at the specified Beginindex and continues to the character at the index endIndex-1. Therefore, the length of the substring is endindex-beginindex.
Example:
"Hamburger". Substring (4, 8) returns "Urge"
"smiles". Substring (1, 5) returns "Mile"
Parameters:Beginindex-Index at the beginning (including). Endindex-the index at the end (not included).
return:The specified substring.
Thrown:Indexoutofboundsexception-If Beginindex is negative, or endindex is greater than the length of this String object, or Beginindex is greater than endindex.