Minimum Element Of Java Vector Using Collection
Chapter:
Collections
Last Updated:
15-07-2016 14:16:06 UTC
Program:
/* ............... START ............... */
import java.util.Collections;
import java.util.Vector;
public class JavaMinimumOfVector {
public static void main(String[] args) {
// create a Vector object
Vector v = new Vector();
// Add elements to Vector
v.add(new Double("44.4324"));
v.add(new Double("455.3532"));
v.add(new Double("342.342"));
Object obj = Collections.min(v);
System.out.println("Minimum Element of Java Vector is : " + obj);
}
}
/* ............... END ............... */
Output
Minimum Element of Java Vector is : 44.4324
Notes:
-
java.util.Collections.min() method is used to return the minimum element of the given collection.
Tags
Collection, Minimum Element Of Java Vector, Java