Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (10.2k points)

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 = ???;

1 Answer

0 votes
by (46k points)

Try:

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

Related questions

Browse Categories

...