List
is the interface, not a class so it can't be instantiated. ArrayList
is most likely what you're after:
ArrayList<Integer> list = new ArrayList<Integer>();
An interface in Java essentially defines a blueprint for the class - a class implementing an interface has to provide implementations of the methods the list defines. But the actual implementation is completely up to the implementing class, ArrayList
in this case.
The JDK also provides LinkedList
- an alternative implementation that again conforms to the list interface. It works very differently to the ArrayList
underneath and as such it tends to be more efficient at adding / removing items half way through the list, but for the vast majority of use cases it's less efficient. And of course if you wanted to define your own implementation it's perfectly possible!
In short, you can't create a list because it's an interface containing no concrete code - that's the job of the classes that implement that list, of which ArrayList
is the most used by far (and with good reason!)
It's also worth noting that in C# a List
is a class, not an interface - that's IList
. The same principle applies though, just with different names.