string.substring()

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 plus2net.com";

System.out.println(str.substring(11));//plus2net.com
System.out.println(str.substring(11,15));//plus
System.out.println(str.substring(4)); // ome to plus2net.com
System.out.println(str.substring(4,5)); // o


All String functions
Java

Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    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 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer