JAVA
What's the difference between two different List declaration?
seoca
2019. 2. 2. 06:44
List<Integer> list = new ArrayList<Integer>();
This declaration enables to use methods including List interface. It allows to to modify your code to another, such as LinkedList or any other List so that, this declaration is the most used one.
ArrayList<Integer> list = new ArrayList<Integer>();
Whereas, if you use this second declaration, It stores ArrayList methods only. You have to change your code whenever you modify your ArrayList to other types of List.