从数组创建 ArrayList [英] Create ArrayList from array
本文介绍了从数组创建 ArrayList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个初始化如下的数组:
I have an array that is initialized like:
Element[] array = {new Element(1), new Element(2), new Element(3)};
我想将此数组转换为 ArrayList
类.
I would like to convert this array into an object of the ArrayList
class.
ArrayList<Element> arraylist = ???;
推荐答案
new ArrayList<>(Arrays.asList(array));
这篇关于从数组创建 ArrayList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文