Table of Contents [hide]
String’s substring method is used to fetch part of a String.It returns a new String which is substring of given String. substring is nothing but subset of given String.
It returns a new String which is substring of given String from specified startIndex(Inclusive)
It returns a new String which is substring of given String from specified startIndex(Inclusive) to endIndex(Exclusive)
When you run above program, you will get below output:
There are two overloaded methods for substring.
Method Signature:
String’s index always starts with 0. In case of substring method, startIndex is always inclusive and endIndex is exclusive
String substring Example:
Was this post helpful?
Let us know if this post was helpful. Feedbacks are monitored on daily basis. Please do provide feedback as that\'s the only way to improve.