Skip to content

Properties

Jacob edited this page Aug 24, 2016 · 1 revision

Capacity

A ByteBuffer's capacity is the number of bytes it can store. It's set at creation, cannot be negative and cannot be changed. It can be retrieved with the #capacity method.

Position

The position is the index of the next element that will be written or read. It's never negative and never greater than the capacity or the limit. It can be retrieved with the #position method and set with the #position= method. It starts at 0.

Limit

The limit is the index from which no data can be read or written. It can be retrieved with the #limit method and set with the #limit= method. It's never negative and starts with the same value as the capacity.

Mark

A ByteBuffer's mark is a way to bookmark a position. A new ByteBuffer has no mark, and is set to the current position with the #mark method. It's never greater than the position and is never negative. The #reset method sets the position of the buffer to the position it had when #mark was called.

Clone this wiki locally