Vector class equals(Object o) method example
Compares the specified Object with this Vector for equality.
Vector class equals(Object o)method example. This example shows you how to use equals(Object o) method.This method Compares the specified Object with this Vector for equality.
Here is the code:-
/*
* @Program that Compares the specified Object with this Vector for equality.
* Equals.java
* Author:-RoseIndia Team
* Date:-24-May-2008
*/
import java.util.*;
public class Equals {
public static void main(String[] args) {
//Constructs a vector
Vector V = new Vector();
V.add("Komal");
Vector V1 = new Vector();
V1.add("Komal");
Vector V3 = new Vector();
V3.add("Mahendra");
//Compares the specified Object with this Vector for equality
boolean b = V.equals(V1);
boolean b1 = V.equals(V3);
//Displays the result
System.out.println("Obj1 equals Obj2: " + b);
System.out.println("Obj1 equals Obj3: " + b1);
}
} |
Output of the program:-
Obj1 equals Obj2: true
Obj1 equals Obj3: false |
|