Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.CopyOnWriteArrayList; import java.util.Arrays; public class CopyOnWriteArrayListToArrayExample12{ public static void main(String[] args) { //Initializing CopyOnWriteArrayList of Integers CopyOnWriteArrayList
numbers = new CopyOnWriteArrayList<>(new Integer[] {1,2,1,4,5,3,3,8}); Object[] toArrayList = {1,2}; //Converting list to array list toArrayList = numbers.toArray(toArrayList); Arrays.toString(toArrayList); //Prints Array List System.out.println("Array List is : " + Arrays.toString(toArrayList)); } }
Output