86
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
Output:
Index of 3 is : 5
Example 2
Output:
Index of 9 is : -1
Example 3
Output:
Index of John is : 2
Example 4
Output:
Index of Jerry is : -1
Next TopicJava CopyOnWriteArrayList