As a C++ oldtimer I have managed to solve my problem but I can not wrap my head around the underlying Java mechanisms here:
VectorThe List is an interface. You cannot create in instance of an interface using new operator. That's why the line List<Object> z = new List<Object>(); gives error. Only classes can be instantiated.
List is an interface, somewhat like a class with some = 0 methods in C++. You can't instantiate it.
But ArrayList<T> "inherits" List<T> (or in Java terms, implements it), so those references are assignment-compatible.
List is an interface, you cannot initialize it. ArrayList implements List, so you can assign an ArrayList instance to a List variable.
"Interface" is like a protocol that an object must comply with.
List is an interface and an interface can't be instantiated.
It's used to implement polymorphism. i.e. a reference of interface type can hold object of any class that implements it.
List<Object> zzz = new ArrayList<Object>();
it works, cause ArrayList implements List.
List isn't class it's an Interface and you can't instantiate the interface object.
ArrayList is the class which was implement the List interface so can able to instantiate the ArrayList object and assign to the List object