Module java.base
Package java.nio

Class IntBuffer

java.lang.Object
java.nio.Buffer
java.nio.IntBuffer
All Implemented Interfaces:
Comparable<IntBuffer>

public abstract sealed class IntBuffer extends Buffer implements Comparable<IntBuffer>
An int buffer.

This class defines four categories of operations upon int buffers:

  • Absolute and relative get and put methods that read and write single ints;

  • Absolute and relative bulk get methods that transfer contiguous sequences of ints from this buffer into an array;

  • Absolute and relative bulk put methods that transfer contiguous sequences of ints from an int array or some other int buffer into this buffer;

  • A method for compacting an int buffer.

Int buffers can be created either by allocation, which allocates space for the buffer's content, by wrapping an existing int array into a buffer, or by creating a view of an existing byte buffer.

Like a byte buffer, an int buffer is either direct or non-direct. A int buffer created via the wrap methods of this class will be non-direct. An int buffer created as a view of a byte buffer will be direct if, and only if, the byte buffer itself is direct. Whether or not an int buffer is direct may be determined by invoking the isDirect method.

Methods in this class that do not otherwise have a value to return are specified to return the buffer upon which they are invoked. This allows method invocations to be chained.

Optional operations

Methods specified as optional operations throw a ReadOnlyBufferException when invoked on a read-only IntBuffer. The methods array and arrayOffset throw an UnsupportedOperationException if the IntBuffer is not backed by an accessible int array (irrespective of whether the IntBuffer is read-only).
Since:
1.4