Java String Substring
# Java substring() Method
[Java String Class](#)
* * *
The substring() method returns a substring of the string.
### Syntax
public String substring(int beginIndex) or public String substring(int beginIndex, int endIndex)
### Parameters
* **beginIndex** -- The beginning index, inclusive (starting from 0).
* **endIndex** -- The ending index, exclusive.
!(#)
### Return Value
A substring of this string.
## Example
public class TutorialTest{public static void main(String args[]){String Str = new String("This is text"); System.out.print("Return Value :"); System.out.println(Str.substring(4)); System.out.print("Return Value :"); System.out.println(Str.substring(4, 10)); }}
The output of the above program is:
Return Value : is text Return Value : is te
* * Java String Class](#)
YouTip