java如何将数组转换为集合
JDK
Element[] array = {new Element(1), new Element(2), new Element(3)};
//转换为集合
List<Element> list = Arrays.asList(array);
//换换为 ArrayList
new ArrayList<>(Arrays.asList(array));
Guava
List<String> l1 = Lists.newArrayList(anotherListOrCollection);
List<String> l2 = Lists.newArrayList(aStringArray);
List<String> l3 = Lists.newArrayList("or", "string", "elements");
Loading...