Extracting A New String From An Existing String Using the substring() Method
stringName.substring(starting index, ending index)
method allows you to extract a new string from an existing string starting at the specified index and continuing though (but not including)
the ending index.
If you want to extract the first three characters from a string, the syntax is:
// result is characters 0 through 2, "Jav"
Remember - substring's second parameter is not included in the new string, just everything before
View the Source