/** * Removes the least recently inserted element from this buffer. * * @return the least recently inserted element * @throws BufferUnderflowException * if the buffer is empty */ public Object remove() { if (isEmpty()) { throw new BufferUnderflowException("The buffer is already empty"); } Object element = elements[start]; elements[start++] = null; if (start >= maxElements) { start = 0; } full = false; return element; }
/** * Returns the least recently inserted element in this buffer. * * @return the least recently inserted element * @throws BufferUnderflowException * if the buffer is empty */ public Object get() { if (isEmpty()) { throw new BufferUnderflowException("The buffer is already empty"); } return elements[start]; }