String.substring(int StartIndex, int EndIndex) part of the string using positions.
StartIndex : Required, Integer showing starting position
EndIndex : (Optional ) Integer showing end position, if not given then till end of the string is considered.

Note that our first position starts with 0 ( Not 1 ).
This image shows position of each char in our string for easy understanding of the below example.
Java substring()
Here are some examples with output.
String str = "Welcome to";

System.out.println(str.substring(4)); // ome to
System.out.println(str.substring(4,5)); // o

All String functions


* indicates required
Subscribe to plus2net

    Post your comments , suggestion , error , requirements etc here

    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 All rights reserved worldwide Privacy Policy Disclaimer