In this example we will show the method to get the min element in a Vector in Java.
Source Code
package com.beginner.examples;
import java.util.Vector;
import java.util.Collections;
public class MinElementOfVector {
public static void main(String[] args) {
Vector vectors = new Vector();
vectors.add(6);
vectors.add(1);
vectors.add(4);
System.out.println("min : " + Collections.min(vectors)); // get the min element
}
}
Output:
min : 1
References
Imported packages in Java documentation: