String class provides number of methods for manipulating the strings. substring() is one of the method of String class that is used to get some part of the original string as String object. substring provides a way of making a copy of a piece of a String. This method has two forms:
substring(int beginIndex): This method returns a new string that will contain a substring of original string starting from the index passed as argument to the method up to the end of the original string.
substring(int beginIndex, int endIndex): This method returns a new string that will contain a substring of original string starting from the index passed as first argument up to one less than the second argument of the method i.e. from beginIndex to (endIndex-1).
To know more about substring go to the url:
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial
Discuss: Java SubString
Post your Comment