java new ArrayListString 创建空集合还有别的写法吗
可以使用以下两种写法创建空集合:
- 使用空的构造函数:
ArrayList<String> list = new ArrayList<>();
- 使用 Collections 类的 emptyList() 方法:
List<String> list = Collections.emptyList();
原文地址: https://www.cveoy.top/t/topic/bxi6 著作权归作者所有。请勿转载和采集!