Manipulating Sets of Bits : BitSet « Collections « Java Tutorial






public void and(BitSet set)
public void or(BitSet set)
public void xor(BitSet set)
public void andNot(BitSet set)
import java.util.BitSet;
public class MainClass {
 public static void main (String args[]) {
    BitSet bites = new BitSet();
    bites.set(0);
    bites.set(1);
    bites.set(2);
    bites.set(3);
    System.out.println(bites);
 
    bites.and(bites);
    System.out.println(bites);
    
    bites.or(bites);
    System.out.println(bites);
    
    bites.xor(bites);
    System.out.println(bites);
    
    bites.andNot(bites);
    System.out.println(bites);

 }
}
{0, 1, 2, 3}
{0, 1, 2, 3}
{0, 1, 2, 3}
{}
{}








9.49.BitSet
9.49.1.Bit Set Operations
9.49.2.Manipulating Sets of Bits
9.49.3.Determining Set Size
9.49.4.Cloning Bit Sets
9.49.5.Set value to BitSet and then do AND, OR and XOR actions
9.49.6.Use BitSet to mark holiday