[Solved] jdk sourcecode about AbstractList


size() and get() are indeed non-static methods from AbstractList. list.size() and l.get() work because they are correctly being invoked from an AbstractList instance (list and l). That instance is provided as an argument to the constructor of SubList and then stored in a private field of the class:

private final AbstractList<E> l;
[...]
SubList(AbstractList<E> list, int fromIndex, int toIndex) {
[...]
    l = list;

The instance of AbstractList must be created (maybe with new) at some point before passing it to the constructor of SubList as an argument.

1

solved jdk sourcecode about AbstractList