or(BitSet): This method is available in java.util.BitSet class of Java.
Syntax:
void java.util.BitSet.or(BitSet set)
This method takes one argument of type BitSet as its parameter. This method performs a logical OR of this bit set with the bit set argument.
Parameters: One parameter is required for this method.
set: a bit set.
Returns: NA
Exceptions: NA
Approach
Java
import java.util.BitSet;public class BitSetor {public static void main(String[] args) {BitSet bitSet = new BitSet(40);bitSet.set(1);bitSet.set(5);bitSet.set(6);bitSet.set(10);BitSet bitSet2 = new BitSet(100);bitSet2.set(11);bitSet2.set(50);bitSet2.set(61);bitSet2.set(1);bitSet.or(bitSet2);System.out.println(bitSet);}}
Output:
{1, 5, 6, 10, 11, 50, 61}
No comments:
Post a Comment