I can type
ArrayList<T> l = new ArrayListList<T>();
and
List<T> l = new ArrayList<T>();
but Java does not allow me to use
List<T> l = new List<T>();
Why?
I can type
ArrayList<T> l = new ArrayListList<T>();
and
List<T> l = new ArrayList<T>();
but Java does not allow me to use
List<T> l = new List<T>();
Why?
List
is an interface, and so it has no method implementations and cannot be instantiated. Your first two examples instantiate an ArrayList
, which is a non-abstract class which implements the List
interface.