Computer Applications
Mention the purpose and syntax of substring() method.
Java String Handling
2 Likes
Answer
The substring() method returns a new string that is a substring of the given string. It has two variations:
Syntax:stringObject.substring(int startindex)
The above method returns a substring beginning from the startindex
and extending to the end of the string.
Syntax:stringObject.substring(int startIndex, int endIndex)
The above method returns a substring beginning from the startindex
and extending to the character at index endIndex - 1
.
Answered By
2 Likes