Get sub string from a string

ReturnMethodSummary
CharSequencesubSequence(int beginIndex, int endIndex)Returns a new character sequence that is a subsequence of this sequence.
Stringsubstring(int beginIndex)Returns a new string that is a substring of this string.
Stringsubstring(int beginIndex, int endIndex)Returns a new string that is a substring of this string.

public class Main {
  public static void main(String[] argv) {
    String str = "java2s.com";
    System.out.println(str.substring(2));
    System.out.println(str.substring(1,3));
  }
}

The output:


va2s.com
av
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.