Java ArrayList indexOf example

Previous
Next
ArrayList’s indexOf method is used to find out first index of object in arraylist.
indexOf method takes object as argument and returns first occurrence of specified element.

Methods:

public int indexOf(Object o)
returns index of first occurrence of element in the ArrayList.

indexOf method return -1 if object is not present in the ArrayList

ArrayList indexOf Example:

When you run above program, you will get below output

Previous
Next

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.

Add Comment

Join Our News Letter - Stay Updated

Subscribe to Awesome Java Content.
You can like our facebook page Java2blog