Java IO Tutorial - Java ShortBuffer.wrap(short[] array, int offset, int length)








Syntax

ShortBuffer.wrap(short[] array, int offset, int length) has the following syntax.

public static ShortBuffer wrap(short[] array,  int offset,  int length)

Example

In the following code shows how to use ShortBuffer.wrap(short[] array, int offset, int length) method.

// w w w  . j  ava  2  s.c om
import java.nio.ShortBuffer;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    ShortBuffer bb = ShortBuffer.wrap(new short[] { 0, 1, 2, 3, 4, 5, 6 },0,3);
    bb.put((short)100);
    System.out.println(Arrays.toString(bb.array()));

  }
}

The code above generates the following result.