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