I'm using the .readAll method of the opencsv library which returns a List<String>. I thought List was an interface and therefore cannot be instantiated, so how can it return a List<> object?
I thought that because ArrayList<> extends the List interface, I could do the following by polymorphism:
ArrayList<String[]> transactions = reader.readAll();
Where .readAll() returns a List<> object. However, it doesn't work as it expects List<> not ArrayList<>.
Why doesn't polymorphism work here, i.e. why can't I assign a List<> interface return value to the implementing class ArrayList? And how can an interface be instantiated as the method return value?
Thanks