I have a question regarding the creation of objects, I will give 3 examples:
List<> nuevaLista = new ArrayList<>();
ArrayList<> nuevaLista= new ArrayList<>();
List <> nuevaLista = new LinkedList<>();
I know that List
is an interface , and that any class that implements List
should implement its abstract methods , but in this case, nuevaLista
, How can it be a variable of type List
if this is not a class?
Out of that doubt, I read that in 1 and 3, nuevaLista
can only implement methods of the interface List
, then what is the difference between instantiating it as ArrayList
or LinkedList
or any class that implements List
?
Thankful for your answers.