Java Get Minimum Value in ArrayList

Tags: ArrayList

In this Java core tutorial we learn how to use the java.util.Collections class to get the minimum element in the java.util.ArrayList object in Java programming language.

How to get minimum element of ArrayList in Java

In Java, with a given ArrayList object we can use the Collections.min(Collection<? extends T> coll) static method to get the minimum element from the ArrayList as the following example Java code.

ArrayListMinValueExample1.java

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ArrayListMinValueExample1 {
    public static void main(String... args) {
        List<Double> list = new ArrayList<>();
        list.add(10.9);
        list.add(2.7);
        list.add(1.5);
        list.add(30.0);

        Double minValue = Collections.min(list);

        System.out.println("ArrayList: " + list);
        System.out.println("Minimum Value: " + minValue);
    }
}
The output as below.
ArrayList: [10.9, 2.7, 1.5, 30.0]
Minimum Value: 1.5

Happy Coding 😊

Java Convert Array to ArrayList

Java Insert Element to ArrayList at Specified Index

How to Traverse ArrayList using Iterator in Java

How to Traverse ArrayList using for each loop in Java

How to Traverse ArrayList using forEach() method in Java

Java Add Element to ArrayList

Java Convert ArrayList to LinkedList

Java Convert ArrayList to Array

Java Convert ArrayList to String

Java Convert ArrayList to Comma Separated String

Java Convert ArrayList to HashSet

Convert Array to List in Java

Java Create New Array with Class Type and Length

Java Create ArrayList using List Interface

Java Get Index of Minimum Value in ArrayList

How to use Java ArrayList with Examples