0
Why is it List<integer> list = new ArrayList();? shouldnt the first one be ArrayList instead of List?
4 Respuestas
+ 2
List is interface which ArrayList and LinkedList implemented and we can use List when we don't sure which specific implementation will be used in one of situations later.
+ 1
list is an Interface and Arraylist and linkedList are Implementation class for List interface. .
u can aslo use like this
ArrayList<Integer>=new ArrayList<Integer>();
or
List=new Arraylist();
both are use to create ArrayList.. 1st one is Generic version and second one is Non generic
0
As List has an Arraylist...i.e Arraylist implements List
- 1
It likes Animal a = new Dog();
The first is superclass ,and the second is subclass.