Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.CopyOnWriteArrayList; public class CopyOnWriteArrayListLastIndexOfExample4{ public static void main(String[] args) { //Initializing CopyOnWriteArrayList of Strings CopyOnWriteArrayList
listOfNames = new CopyOnWriteArrayList<>(new String[] {"Tom","Harry","John","John","John","Jerry"}); //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 Lincoln is : " + listOfNames.lastIndexOf("Lincoln", 5)); } }
Output