Java CharBuffer.get(int index)

Syntax

CharBuffer.get(int index) has the following syntax.

public abstract char get(int index)

Example

In the following code shows how to use CharBuffer.get(int index) method.


/*from  w w w.  ja  va2 s.co m*/
import java.nio.CharBuffer;

public class Main {
  public static void main(String[] args) {
    CharBuffer cb1 = CharBuffer.allocate(5);
    cb1.put(2,'j');
    cb1.rewind();

    System.out.println(cb1.get(2));
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.nio »




Buffer
ByteBuffer
ByteOrder
CharBuffer
DoubleBuffer
FloatBuffer
IntBuffer
LongBuffer
MappedByteBuffer
ShortBuffer