Returns

public
final
int
arrayOffset()

Returns the offset into the array returned by array of the first
element of the buffer (optional operation). The backing array (if there is one)
is not necessarily the same size as the buffer, and position 0 in the buffer is
not necessarily the 0th element in the array. Use
buffer.array()[offset + buffer.arrayOffset() to access element offset
in buffer.

Use hasArray to ensure this method won't throw.
(A separate call to isReadOnly is not necessary.)

Returns

Throws

public
final
boolean
hasArray()

Returns true if array and arrayOffset won't throw. This method does not
return true for buffers not backed by arrays because the other methods would throw
UnsupportedOperationException, nor does it return true for buffers backed by
read-only arrays, because the other methods would throw ReadOnlyBufferException.

The sliced buffer's capacity will be this buffer's remaining(),
and its zero position will correspond to this buffer's current position.
The new buffer's position will be 0, limit will be its capacity, and its
mark is cleared. The new buffer's read-only property and byte order are
the same as this buffer's.

The new buffer shares its content with this buffer, which means either
buffer's change of content will be visible to the other. The two buffers'
position, limit and mark are independent.