Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.CopyOnWriteArrayList; public class CopyOnWriteArrayListIndexOfExample1{ public static void main(String[] args) { //Initializing CopyOnWriteArrayList of Integers CopyOnWriteArrayList
numbers = new CopyOnWriteArrayList<>(new Integer[] {1,2,1,4,5,3,3,3}); //Prints index of the first occurrence of the element in this list at position index or later in the list and -1 if the element is not found. System.out.println("Index of 3 is : " + numbers.indexOf(3, 1)); } }
Output