Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.CopyOnWriteArrayList; import java.util.Arrays; public class CopyOnWriteArrayListToArrayExample4{ public static void main(String[] args) { //Initializing CopyOnWriteArrayList of Strings CopyOnWriteArrayList
listOfNames = new CopyOnWriteArrayList<>(new String[] {}); Object[] toArrayList = null; //Converting list to array list toArrayList = listOfNames.toArray(); Arrays.toString(toArrayList); //Prints Array List System.out.println("Array List is : " + Arrays.toString(toArrayList)); } }
Output