VOOZH about

URL: https://www.geeksforgeeks.org/java/vector-equals-method-in-java/

⇱ Vector equals() Method in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Vector equals() Method in Java

Last Updated : 11 Jul, 2025
The java.util.vector.equals(Object obj) method of Vector class in Java is used verify the equality of an Object with a vector and compare them. The list returns true only if both Vector contains same elements with same order. Syntax:
first_vector.equals(second_vector)
Parameters: This method accepts a mandatory parameter second_vector which refers to the second Vector to be compared to the first Vector. Return value: The method returns true if the equality holds and both the objects and vector are equal else it returns false. Below programs are used to illustrate the working of the java.util.Vector.elements() method: Program 1:
Output:
The Vector is: [Geeks, 4, Geeks, Welcomes, You]
The Vector is: [Geeks, 4, Geeks, Welcomes, You]
Are both of them equal? true
Program 2 :
Output:
The Vector is: [10, 15, 20, 25, 30]
The Vector is: [10, 15, 20, 25, 30, 40]
Are both of them equal? false
Comment