Home » Java CopyOnWriteArrayList indexOf() Method with Examples

Java CopyOnWriteArrayList indexOf() Method with Examples

by Online Tutorials Library

Java CopyOnWriteArrayList indexOf() Method

The indexOf() method of java CopyOnWriteArrayList class returns the index of the first occurrence of the specified element in this list at position index or later in the list. If the element is not found, this method will return -1.

Syntax:

Parameters:

e ? It is the element to search

index ? It is the index to start searching

Returns:

This method returns the index of the first occurrence of the element in this list at position index. If the element is not found, this method will return -1.

Example 1

Test it Now

Output:

Index of 3 is : 5  

Example 2

Test it Now

Output:

Index of 9 is : -1  

Example 3

Test it Now

Output:

Index of John is : 2  

Example 4

Test it Now

Output:

Index of Jerry is : -1  

You may also like