Java Data Type Tutorial - Java String(byte[] bytes, int offset, int length) Constructor








Syntax

String(byte[] bytes, int offset, int length) constructor from String has the following syntax.

public String(byte[] bytes,  int offset,  int length)

Example

In the following code shows how to use String.String(byte[] bytes, int offset, int length) constructor.

public class Main {
  public static void main(String args[]) {
    byte ascii[] = { 65, 66, 67, 68, 69, 70 };

    String s2 = new String(ascii, 2, 3);
    System.out.println(s2);
  }
}

The code above generates the following result.