幾個快速添加list的方法
1. 使用Collections.addAll()方法,前提仍是須要手動 new ArrayList
ArrayList<String> s = new ArrayList(); Collections.addAll(s,"1","2","3")
2. 使用Arrays.asList(...args) 直接返回一個List
List<String> s = Arrays.asList("1","2","3")
3. 若是引入了Guava的工具包,可使用他的Lists.newArrayList(...args)方法
List<String> list = Lists.newArrayList("1","2","3")
4. 若是是Java9,可使用自帶的List類
List<String> s = List.of("1","2","3")