andNot(BitSet): This method is available in java.util.BitSet class of Java.
Syntax:
void java.util.BitSet.andNot(BitSet set)
This method takes one argument of the type BitSet as its parameter. This method clears all of the bits in this BitSet whose corresponding bit is set in the specified BitSet.
Parameters: One parameter is required for this method.
set: the BitSet with which to mask this BitSet.
Returns: NA
Exceptions: NA
Approach
Java
import java.util.BitSet;public class BitSetandNot {public static void main(String[] args) {BitSet bitSet = new BitSet(100);bitSet.set(1);bitSet.set(5);bitSet.set(6);bitSet.set(10);BitSet bitSet2 = new BitSet(100);bitSet2.set(5);bitSet2.set(1);bitSet2.set(9);bitSet2.set(8);bitSet.andNot(bitSet2);System.out.println(bitSet);}}
Output:
{6, 10}
No comments:
Post a Comment