Java examples for Language Basics:String
Use the substring() method to obtain a portion of the String between two different positions.
public class Main { public static void main(String[] args){ String originalString = "This is the original String"; System.out.println(originalString.substring(0, originalString.length())); System.out.println(originalString.substring(5, 20)); System.out.println(originalString.substring(12)); }/* w ww . ja va 2 s . com*/ }