BitSet void andNot(BitSet set) Method Example Program


Clears all of the bits in this BitSet whose corresponding bit is set in the specified BitSet.

Program

package com.candidjava;
import java.util.BitSet;

/**
 * @author :vinod kumar v
 * @description :andNot(BitSet set)Clears all of the bits in this BitSet whose
 *              corresponding bit is set in the specified BitSet.
 * */

public final class BitSetAndNot {
	public static void main(String[] args) {

		BitSet obj = new BitSet(8);
		BitSet obj1 = new BitSet(8);

		obj.set(0);
		obj.set(1);
		obj.set(2);
		obj.set(3);

		obj1.set(2);
		obj1.set(4);
		obj1.set(6);
		obj1.set(8);

		System.out.println("The Value in obj:" + obj);
		System.out.println("The Value in obj1" + obj1);

		obj.andNot(obj1);
		System.out.println("" + obj);

	}
}

Output

The Value in obj:{0, 1, 2, 3}
The Value in obj1{2, 4, 6, 8}
{0, 1, 3}

Explanation

public void andNot(BitSet set)
Clears all of the bits in this BitSet whose corresponding bit is set in the specified BitSet.
Parameters:
set - the BitSet with which to mask this BitSet


Related Post

Comments


©candidjava.com