### Question:
BufferCache implements List<ByteBuffer> { @Override public List<ByteBuffer> subList(int fromIndex, int toIndex) { if (fromIndex < getMinimumAvailableIndex() || toIndex > getMaximumAvailableIndex()) { throw new IndexOutOfBoundsException(); } List<ByteBuffer> array = new ArrayList<>(toIndex - fromIndex); ListIterator<java.nio.ByteBuffer> iter = listIterator(fromIndex); while (iter.hasNext()) { final ByteBuffer buffer = iter.next(); array.add(buffer.duplicate().order(buffer.order())); } return array; } BufferCache();  BufferCache(int cacheCapacity, int bufferCapacity, ByteOrder order); @Override boolean add(ByteBuffer src); @Override void add(int index, ByteBuffer src); @Override boolean addAll(Collection<? extends ByteBuffer> c); @Override boolean addAll(int index, Collection<? extends ByteBuffer> c); @Override void clear(); @Override boolean contains(Object o); @Override boolean containsAll(Collection<?> c); @Override ByteBuffer get(int index); @Override int indexOf(Object o); @Override boolean isEmpty(); @Override Iterator<ByteBuffer> iterator(); @Override int lastIndexOf(Object o); @Override ListIterator<ByteBuffer> listIterator(); @Override ListIterator<ByteBuffer> listIterator(int index); @Override ByteBuffer remove(int index); @Override boolean remove(Object o); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override ByteBuffer set(int index, ByteBuffer src); @Override int size(); @Override List<ByteBuffer> subList(int fromIndex, int toIndex); @Override Object[] toArray(); @SuppressWarnings("unchecked") T[] toArray(T[] a); static final int DEFAULT_BUFFER_CAPACITY; static final int DEFAULT_CACHE_CAPACITY; }### Answer:
@Test public void subList() { for (int i=0; i < 20; i++) { ByteBuffer src = createBuffer(Integer.toString(i)); assertTrue(cache.add(src)); } assertEquals(20, cache.size()); List<ByteBuffer> list = cache.subList(17, 19); assertEquals(2, list.size()); }