### Question:
FlexBuffer { final public FlexBuffer compact() { if (index == 0) return this; int n = avail(); if (n == 0) { reset(); return this; } System.arraycopy( buffer, index, buffer, 0, n ); index = 0; length = n; return this; } FlexBuffer();  FlexBuffer( byte[] buffer );  FlexBuffer( byte[] buffer, int length );  FlexBuffer( byte[] buffer, int index, int length ); final byte[] getBuf(); final int length(); final FlexBuffer setLength( int length ); final int index(); final FlexBuffer setIndex( int index ); final int avail(); final FlexBuffer reset(); final FlexBuffer compact(); final int get(); final int get( byte[] buf ); final int get( byte[] buf, int off, int len ); final byte getByte(); final short getShort(); final int getInt(); final long getLong(); final float getFloat(); final double getDouble(); final void getFully( byte[] b ); final FlexBuffer put( int b ); final FlexBuffer put( byte[] buf ); final FlexBuffer put( byte[] buf, int off, int len ); final FlexBuffer put( FlexBuffer buf ); final FlexBuffer put( FlexBuffer buf, int len ); final void putByte( byte value ); final void putShort( short value ); final void putInt( int value ); final void putLong( long value ); final void putFloat( float value ); final void putDouble( double value ); final FlexBuffer skip( int len, boolean put ); final byte[] getAvailBytes();  }### Answer:
@Test public void compact() throws Exception { FlexBuffer buf = new FlexBuffer( new byte[] { 1, 2, 3, 4, 5 }, 1, 3 ); buf.compact(); checkBuf( buf, 3, 0, 3 ); assertEquals( 2, buf.get() ); assertEquals( 3, buf.get() ); assertEquals( 4, buf.get() ); }