Create Array List from array

Submitted 3 years, 6 months ago
Ticket #240
Views 231
Language/Framework Java
Priority Low
Status Closed

I have an array that is initialized like:

Element[] array = {new Element(1), new Element(2), new Element(3)};

I would like to convert this array into an object of the ArrayList class.

ArrayList<Element> arraylist = ???;
Submitted on Oct 19, 20
add a comment

1 Answer

Verified

new ArrayList<>(Arrays.asList(array));

Submitted 3 years, 5 months ago


Latest Blogs