convert java list to array

Java
// Java program to convert a List to an array 
// using toArray() in a loop. 
import java.util.*; 
  
public class GeeksforGeeks { 
    public static void main(String[] args) 
    { 
        List<String> list = new LinkedList<String>(); 
        list.add("Geeks"); 
        list.add("for"); 
        list.add("Geeks"); 
        list.add("Practice"); 
  
        String[] arr = list.toArray(new String[0]); 
  
        for (String x : arr) 
            System.out.print(x + " "); 
    } 
} 
Integer[] arr = new Integer[al.size()]; 
arr = al.toArray(arr); 
Source

Also in Java: