The Java NIO.2 API comes with an implementation of a byte buffer called java.nio.ByteBuffer. Basically, this is an array of bytes (byte[]) that's wrapped with a suite of methods dedicated to manipulating this array (for example, get(), put(), and so on). A circular buffer (cyclic buffer, ring buffer, or circular queue) is a fixed-size buffer that's connected end-to-end. The following diagram shows us what a circular queue looks like:
A circular buffer relies on a pre-allocated array (pre-allocated capacity), but some implementations may require a resizing capability as well. The elements are written/added to the back ...