lastIndexOf(Object o) method

lastIndexOf(Object o): This lastindexof Object-o method utilizes to get the last index of a specified element. It returns the index value of the last occurrence of the element if LinkedList. It returns the int value. If the element doesn’t present in LinkedList it will return -1.

int lastIndexOf(Object o)

Where, Object represents the type of elements in LinkedList.
o, is the element which you want to find in LinkedList.

import java.util.LinkedList;
public class ExampleOfLinkedList 
	public static void main(String[] args) 
		LinkedList<String> listOfNames = new LinkedList<String>();
		System.out.println("Index value of element = "+ 

Output: Index value of element = 1

Leave a Comment