ListView extends CollectionView<E> implements List<E> { public List<E> subList(int fromIndex, int toIndex) { return new ListView<>(((List<E>) this.collection).subList(fromIndex, toIndex)); } ListView(List<E> list); void add(int index, E element); boolean addAll(int index, Collection<? extends E> collection); boolean equals(Object obj); E get(int index); int hashCode(); int indexOf(Object obj); int lastIndexOf(Object obj); ListIterator<E> listIterator(); ListIterator<E> listIterator(int index); E remove(int index); E set(int index, E element); List<E> subList(int fromIndex, int toIndex);  }
@Test public void testSubList() { for (int i = 0; i < 10; ++i) { this.source.add(String.valueOf(i)); } for (int i = 0; i < this.source.size() - 3; ++i) { List sublist = ((ListView) this.testobj).subList(i, i + 3); assertTrue(sublist instanceof ListView); assertEquals(3, sublist.size()); for (int j = i; j < i + 3; ++j) { assertTrue(sublist.contains(String.valueOf(j))); } } for (int i = 0; i < this.source.size(); ++i) { List sublist = ((ListView) this.testobj).subList(i, i); assertTrue(sublist instanceof ListView); assertEquals(0, sublist.size()); } }