AbstractList class is an abstract class which extends the class AbstractCollection and implements the interface List.

public abstract class AbstractList<E> extends AbstractCollection<E> implements List<E>

AbstractList didn't implement get() and size() methods. The class extends AbstractList must provide those two methods implementation.

We can wrap an internal ArrayList and add some control on it.

import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class TestAbstractList2<T> extends AbstractList<T> {
    public static void main (String [] args ) {
        TestAbstractList2<Integer> list = new TestAbstractList2<Integer>();
        list.add(0, 23);
        System.out.println("size:" + list.size() + "get: " + list.get(0));
        TestAbstractList2<String> liststr = new TestAbstractList2<String>();
        System.out.println("size:" + liststr.size() + "get: " + liststr.get(0));
    protected List<T> list = Collections.emptyList();
    public TestAbstractList2<T> unlock() {
        this.list = new ArrayList<T>();
        return this;
    public int size() {
        return list.size();
    public T get ( int index ) {
        return list.get(index);
    public void add( int index, T e) {
        list.add(index, e);
    public boolean add(T o) {
        return list.add(o);

This list can only available after unlock calling.

AbstractList provides common implementation of List to reduce code duplication.

You extends AbstractList to create your custom made List.