Returns a part of consecutive elements of this list as a view. The
returned view will be of zero length if start equals end. Any change that
occurs in the returned subList will be reflected to the original list,
and vice-versa. All the supported optional operations by the original
list will also be supported by this subList.
This method can be used as a handy method to do some operations on a sub
range of the original list, for example
If the original list is modified in other ways than through the returned
subList, the behavior of the returned subList becomes undefined.
The returned subList is a subclass of AbstractList. The subclass stores
offset, size of itself, and modCount of the original list. If the
original list implements RandomAccess interface, the returned subList
also implements RandomAccess interface.
The subList's set(int, Object), get(int), add(int, Object), remove(int),
addAll(int, Collection) and removeRange(int, int) methods first check the
bounds, adjust offsets and then call the corresponding methods of the
original AbstractList. addAll(Collection c) method of the returned
subList calls the original addAll(offset + size, c).
The listIterator(int) method of the subList wraps the original list
iterator. The iterator() method of the subList invokes the original
listIterator() method, and the size() method merely returns the size of
All methods will throw a ConcurrentModificationException if the modCount
of the original list is not equal to the expected value.