Listvs. ArrayList(1) List? myList new ArrayList?()(2) ArrayList? myList new ArrayList?
List vs. ArrayList
(1) List<?> myList = new ArrayList<?>();
(2) ArrayList<?> myList = new ArrayList<?>();
use (2) if code is the "owner" of the list. This is for example true for local-only variables. There is no reason to use the abstract type List instead of ArrayList. Another example to demonstrate ownership:
[解决办法]
我比较常用的是List<String> creditCardYears = new ArrayList<String>();
[解决办法]
List<T> XXX = new ArrayList<T>();
List是一个接口吧,而arraylits是实现了这个接口的一个类
[解决办法]
区别在于是不是需要使用ArrayList独有的方法
