Java Data Type Tutorial - Java String(char[] value, int offset, int count) Constructor








Syntax

String(char[] value, int offset, int count) constructor from String has the following syntax.

public String(char[] value,  int offset,  int count)

Example

In the following code shows how to use String.String(char[] value, int offset, int count) constructor.

public class Main {
  public static void main(String args[]) {
    
    char charArray[] = { 'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o','m' };
    String s4 = new String(charArray, 6, 3);

    System.out.println(s4);
  }
}

The code above generates the following result.