Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.CopyOnWriteArrayList; public class CopyOnWriteArrayListLastIndexOfExample1{ public static void main(String[] args) { //Initializing CopyOnWriteArrayList of Integers CopyOnWriteArrayList
numbers = new CopyOnWriteArrayList<>(new Integer[] {1,2,1,4,5,3,3,8}); //Prints the index of the last occurrence of the specified element in this list, searching backwards from index, or returns -1 if the element is not found. System.out.println("Last Index of 3 is : " + numbers.lastIndexOf(3, 7)); } }
Output