0 votes
1 view
in Java by (13.1k points)
Can anyone help me how I can able to convert the list into an array in Java?

1 Answer

0 votes
by (26.7k points)

You can use either:

Foo[] array = list.toArray(new Foo[0]);

Or, you can go for:

Foo[] array = new Foo[list.size()];

list.toArray(array); // fill the array

I hope this will help.

Want to know more about Java? Prefer this tutorial on Core Java Tutorial.

Want to become a Java Expert? Join Java Course now!!

Related questions

0 votes
1 answer
asked Jul 10, 2019 in Java by Ritik (3.5k points)
0 votes
1 answer
0 votes
1 answer
asked Jul 15, 2019 in Python by Sammy (47.8k points)
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...