util. LinkedList. indexOf(Object element) method is used to check and find the occurrence of a particular element in the list. If the element is present then the index of the first occurrence of the element is returned otherwise -1 is returned if the list does not contain the element.
Does a linked list have an index?
It may not be efficient to retrieve items from a linked list by index, but linked lists do have indices, and sometimes you just need to retrieve an item at a certain index.
Are Linked Lists indexed in Java?
2 Answers. They have a logical index, yes - effectively the number of times you need to iterate, starting from the head, before getting to that node.