equals(Object): This method is available in java.util.Vector class of Java.
Syntax:
boolean java.util.Vector.equals(Object o)
This method takes one argument. This method compares the specified Object with this Vector for equality. Returns true if and only if the specified Object is also a List, both Lists have the same size, and all corresponding pairs of elements in the two lists are equal.
Parameters: One parameter is required for this method.
o: the Object to be compared for equality with this Vector.
Returns: true if the specified Object is equal to this Vector.
Exceptions: NA
Approach
Java
import java.util.Vector;public class Vectorequals {public static void main(String[] args) {Vector<String> vector = new Vector<>();vector.add("Hello");vector.add("Java");vector.add("C++");vector.add("Program");System.out.println(vector.equals(vector));}}
Output:
true
No comments:
Post a Comment