BitSet boolean intersects(BitSet set) Method Example Program


Returns true if the specified BitSet has any bits set to true that are also set to true in this BitSet.

Program

package com.candidjava;

import java.util.BitSet;

/**
 * @author :vinod kumar v
 * @description :The intersects(BitSet set) method returns true if the specified
 *              BitSet has any bits set to true that are also set to true in
 *              this BitSet.
 * */

public final class BitSetIntersect {
	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);

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

	}
}

Output

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

Explanation

public boolean intersects(BitSet set)
Returns true if the specified BitSet has any bits set to true that are also set to true in this BitSet.
Parameters:
set - BitSet to intersect with
Returns:
boolean indicating whether this BitSet intersects the specified BitSet


Related Post

Comments


©candidjava.com