Java Data Type Tutorial - Java String.getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)








Syntax

String.getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) has the following syntax.

public void getChars(int srcBegin,  int srcEnd,  char[] dst,  int dstBegin)

Example

In the following code shows how to use String.getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) method.

 
public class Main {
  public static void main(String args[]) {
//  w w w  . j a va  2 s .c  om
    String s = "This is a test string from java2s.com.";
    int start = 10;
    int end = 14;
    char buf[] = new char[end - start];

    s.getChars(start, end, buf, 0);
    System.out.println(buf);
  }
}

Here is the output of this program: