Java ShortBuffer.put(int index, short s)

Syntax

ShortBuffer.put(int index, short s) has the following syntax.

public abstract ShortBuffer put(int index,  short s)

Example

In the following code shows how to use ShortBuffer.put(int index, short s) method.


import java.nio.ShortBuffer;
import java.util.Arrays;
/*  ww w  .j  ava 2s  .c o  m*/
public class Main {
  public static void main(String[] args) {
    ShortBuffer bb = ShortBuffer.wrap(new short[] { 0, 1, 2, 3, 4, 5, 6 });
    bb.put(0,(short)100);
    System.out.println(Arrays.toString(bb.array()));

  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.nio »




Buffer
ByteBuffer
ByteOrder
CharBuffer
DoubleBuffer
FloatBuffer
IntBuffer
LongBuffer
MappedByteBuffer
ShortBuffer