
- Java.util Package Classes
- Java.util - Home
- Java.util - ArrayDeque
- Java.util - ArrayList
- Java.util - Arrays
- Java.util - BitSet
- Java.util - Calendar
- Java.util - Collections
- Java.util - Currency
- Java.util - Date
- Java.util - Dictionary
- Java.util - EnumMap
- Java.util - EnumSet
- Java.util - Formatter
- Java.util - GregorianCalendar
- Java.util - HashMap
- Java.util - HashSet
- Java.util - Hashtable
- Java.util - IdentityHashMap
- Java.util - LinkedHashMap
- Java.util - LinkedHashSet
- Java.util - LinkedList
- Java.util - ListResourceBundle
- Java.util - Locale
- Java.util - Observable
- Java.util - PriorityQueue
- Java.util - Properties
- Java.util - PropertyPermission
- Java.util - PropertyResourceBundle
- Java.util - Random
- Java.util - ResourceBundle
- Java.util - ResourceBundle.Control
- Java.util - Scanner
- Java.util - ServiceLoader
- Java.util - SimpleTimeZone
- Java.util - Stack
- Java.util - StringTokenizer
- Java.util - Timer
- Java.util - TimerTask
- Java.util - TimeZone
- Java.util - TreeMap
- Java.util - TreeSet
- Java.util - UUID
- Java.util - Vector
- Java.util - WeakHashMap
- Java.util Package Extras
- Java.util - Interfaces
- Java.util - Exceptions
- Java.util - Enumerations
- Java.util Useful Resources
- Java.util - Useful Resources
- Java.util - Discussion
java.util.Vector.equals() Method
Description
The equals(Object o) method is used to compare the specified Object with this Vector for equality. It 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.Two Lists are defined to be equal if they contain the same elements in the same order.
Declaration
Following is the declaration for java.util.Vector.equals() method
public boolean equals(Object o)
Parameters
o − This is the Object to be compared for equality with this Vector.
Return Value
The method call returns true if the specified Object is equal to this Vector.
Exception
NA
Example
The following example shows the usage of java.util.Vector.equals() method.
package com.tutorialspoint; import java.util.Vector; public class VectorDemo { public static void main(String[] args) { // create two empty Vectors an initial capacity of 4 Vector<Integer> firstvec = new Vector<Integer>(4); Vector<Integer> secondvec = new Vector<Integer>(4); // additing in firstvec firstvec.add(4); firstvec.add(3); firstvec.add(2); // additing in secondvec secondvec.add(4); secondvec.add(3); secondvec.add(2); // let us print all the elements available in vector System.out.println("Testing equality of firstvec and secondvec :"+ firstvec.equals(secondvec)); } }
Let us compile and run the above program, this will produce the following result.
Testing equality of firstvec and secondvec :true
java_util_vector.htm
Advertisements