Java Collection Tutorial - Java Collections.min(Collection <? extends T> coll)








Syntax

Collections.min(Collection <? extends T> coll) has the following syntax.

public static <T extends Object &amp; Comparable <? super T>> T min(Collection <? extends T> coll)

Example

In the following code shows how to use Collections.min(Collection <? extends T> coll) method.

/*  w ww .  j a  v a  2  s  .  com*/
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

public class Main {
   public static void main(String args[]) { 
      // create link list object 
      List<Integer>  list = new LinkedList<Integer> ();
    
      // populate the list  
      list.add(-8);  
      list.add(4);  
      list.add(-5);  
      list.add(1); 
    
      System.out.println("Min value is: " + Collections.min(list));          
   }  
}

The code above generates the following result.