# Insert the specified element at the specified position in Java CopyOnWriteArrayList

Java 8ProgrammingObject Oriented Programming

Using the add() method, insert the specified element at the specified position in the CopyOnWriteArrayList.

The syntax is as follows

void add(int index, E ele)

Here, the parameter index is where you want to insert the element and ele is the element to be inserted to this list. To work with CopyOnWriteArrayList class, you need to import the following package

import java.util.concurrent.CopyOnWriteArrayList;

The following is an example to add elements in the CopyOnWriteArrayList class in Java

## Example

Live Demo

import java.util.concurrent.CopyOnWriteArrayList;
public class Demo {
public static void main(String[] args) {
CopyOnWriteArrayList<Integer> arrList = new CopyOnWriteArrayList<Integer>();
}
CopyOnWriteArrayList Elements = [400, 500, 650, 100, 250, 700, 800]