Write a Java program to Find minimum element in ArrayList


This Java code demonstrates how to find the minimum element in an ArrayList using the Collections.min() method. First, an ArrayList named num_list is created and populated with five elements using the add() method.

Then, the Collections.min() method is called on the num_list object to find the minimum element. The result is stored in the max_num variable. Finally, the result is printed to the console using the println() method.

Source Code

import java.util.ArrayList;
import java.util.Collections;
public class Minimum_Elemen
{
	public static void main(String[] args)
	{
		ArrayList num_list = new ArrayList();
		num_list.add("80");
		num_list.add("18");
		num_list.add("48");
		num_list.add("37");
		num_list.add("24");
		Object max_num = Collections.min(num_list);
		System.out.println("Maximum Element ArrayList is : " + max_num);
	}
}

Output

Maximum Element ArrayList is : 18

Example Programs