- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Find the minimum element of a Vector in Java

The minimum element of a Vector can be obtained using the java.util.Collections.min() method. This method contains a single parameter i.e. the Vector whose minimum element is determined and it returns the minimum element from the Vector.

A program that demonstrates this is given as follows −

## Example

import java.util.Collections; import java.util.Vector; public class Demo { public static void main(String args[]) { Vector vec = new Vector(); vec.add(7); vec.add(3); vec.add(9); vec.add(5); vec.add(8); System.out.println("The Vector elements are: " + vec); System.out.println("The minimum element of the Vector is: " + Collections.min(vec)); } }

The output of the above program is as follows −

The Vector elements are: [7, 3, 9, 5, 8] The minimum element of the Vector is: 3

Now let us understand the above program.

The Vector is created. Then Vector.add() is used to add the elements to the Vector. The vector is displayed. Collections.min() is used to find the minimum element of the Vector and that is displayed. A code snippet which demonstrates this is as follows −

Vector vec = new Vector(); vec.add(7); vec.add(3); vec.add(9); vec.add(5); vec.add(8); System.out.println("The Vector elements are: " + vec); System.out.println("The minimum element of the Vector is: " + Collections.min(vec));

- Related Articles
- Find the maximum element of a Vector in Java
- Find minimum element of HashSet in Java
- Find minimum element of ArrayList with Java Collections
- Search an element of Vector in Java
- Replace an element at a specified index of the Vector in Java
- How to find the index of an element in a vector in R?
- How to find the index of the minimum and maximum value of a vector in R?
- How to find the maximum element of a Vector using STL in C++?
- How to find minimum value in a numerical vector which is written as a character vector in R?
- How to minus every element of a vector with every element of another vector in R?
- How to find the indexes of minimum values in a vector if there are ties in R?
- How to find the position of minimum value in a vector that contains integers as strings in R?
- Set the size of a Vector in Java
- How to multiply each element of a larger vector with a smaller vector in R?
- PHP program to find the minimum element in an array

Advertisements