Convert a List (ArrayList) to an Array

This piece of Java code shows how to convert a List, in this case an ArrayList, to an Array by calling the method toArray() on the List object.
The toArray() method returns an array of the same type as the array provided as an argument to the method. The argument can be an empty array as in the example below.

The code above generate the following output (the elements are ordered similarly in the array as in the list):

Search for more Java info on this site here:
Custom Search

Please type any questions here.