equals(Object): This method is available in java.util.BitSet class of Java.
Syntax:
boolean java.util.BitSet.equals(Object obj)
This method takes one argument. This method compares this object against the specified object.
Note: The result is true if and only if the argument is not null and is a BitSet object that has exactly the same set of bits set to true as this bitset.
Parameters: One parameter is required for this method.
obj: the object to compare with.
Returns: true if the objects are the same; false otherwise.
Exceptions: NA
Approach
Java
import java.util.BitSet;public class BitSetequals {public static void main(String[] args) {BitSet bitSet = new BitSet(20);bitSet.set(1);bitSet.set(5);bitSet.set(6);bitSet.set(10);BitSet obj = new BitSet(20);obj.set(1);obj.set(5);obj.set(6);obj.set(10);System.out.println(bitSet.equals(obj));}}
Output:
true
No comments:
Post a Comment