0
votes

I have BitSet1 - {2,4,6,8} and another BitSet2 - {10,20}. How to combine the two Bitsets and get the final BitSet as {2,4,6,8,10,20}. Please help ?

1
What exactly is preventing you from arriving at a solution? - Nicholas K
Use a loop? Try something? What is blocking you? - jhamon
I don't know how to combine the two BitSets - Spidey
Questions asking for homework help must include a summary of the work you've done so far to solve the problem, and a description of the difficulty you are having solving it (help center, How to Ask). - Zabuzard

1 Answers

6
votes

Use BitSet.or(BitSet) to include all elements of the bit set passed as argument into the current bit set.