티스토리 뷰




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. 





'JAVA' 카테고리의 다른 글

Reference Data Type in Java  (0) 2019.02.20
Anonymous class in Java  (0) 2019.02.20
Upcasting (Object type casting) in java  (0) 2019.01.30
String class in Java  (0) 2019.01.20
Collection framework - ArrayList  (0) 2019.01.17