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.
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