toArray() Method : Java.util.ArrayList


Declaration :

Explanation :

Purpose Method returns an array having all the elements in this list in sequence.
Parameters arr ==> Array into which the elements of the list are to be stored
Return Value Array containing the elements of the list
Exception ArrayStoreException ==> If the runtime type of the specified array is not a supertype of the runtime type of every element in this list
NullPointerException ==> If the specified array is null

Example

The following example shows the usage of java.util.Arraylist.toArray(E) method.

Output :