Back
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
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!!
31k questions
32.8k answers
501 comments
693 users