Code example for BufferUnderflowException

0
    } 
 
    @Override 
    public byte get() { 
        if (!hasRemaining()) { 
            throw new BufferUnderflowException();
        } 
        return heap[offset + pos++];
    } 
 
    @Override 
    public byte get(int index) {
        if (index < 0 || index >= lim) {
            throw new IndexOutOfBoundsException();
        } 
        return heap[offset + index];
    } 
 
    @Override 
    public HeapBuffer put(byte b) {