Java IO Tutorial - Java ShortBuffer.allocate(int capacity)








Syntax

ShortBuffer.allocate(int capacity) has the following syntax.

public static ShortBuffer allocate(int capacity)

Example

In the following code shows how to use ShortBuffer.allocate(int capacity) method.

//from w  w  w .  ja v  a  2s .  com
import java.nio.ShortBuffer;

public class Main {
  public static void main(String[] args) {
    ShortBuffer bb = ShortBuffer.allocate(10);
    bb.put((short)100);
    System.out.println(bb.arrayOffset());

  }
}

The code above generates the following result.