AbstractList class |
What operations can be implemented in AbstractList class to be shared?
For example:
public E getFirst() \{ return get(0); \}
However, there is no method get(int n) in the abstract class. There are two things going on here. First AbstractList implements interface List, which promises that there is such a get method. Normally this would force AbstractList to implement it. However, we can omit the implementations of required methods if we declare the class to be abstract.
When a class is declared to be abstract, we may not call its constructor, even if one is defined. Instead, the class may only be used to inherit from (even its constructor). We'll see in the code below how that works with the get(int n) method.
See details in AbstractList and AbstractCollection classes.
AbstractList class |