Collections

Find Minimum Maximum value in ArrayList

Find Minimum Maximum value in ArrayList Java example shows how to find minimum and maximum value in ArrayList. Example also shows how to find minimum maximum value along with index in Java ArrayList.

How to find Minimum Maximum value in ArrayList?

There are a couple of ways to find minimum and maximum value in Java ArrayList.

1)    Find Min Max value in ArrayList using Collections class

You can use min and max methods of Collections class.

This method returns minimum element/value of the specified collection according to the natural ordering of the elements.

This method returns maximum element/value of the specified collection according to the natural ordering of the elements.

Example

Output

How to find index of minimum maximum elements in Java ArrayList?

If you want to find index of minimum or maximum element instead of value, you can use indexOf method of ArrayList class.

This method returns the index of specified element. If element is not found in the ArrayList, it returns -1.

Output

2)    Find Min Max value in ArrayList using for loop

If you want to find min max values without using Collections class, you can use for loop to find the same as given below.

Output

Please let us know your views in the comments section below.

Join 1000+ fellow learners! Enter your email address below: