Cloning Bit Sets : BitSet « Collections « Java Tutorial






The BitSet class implements the Cloneable interface, providing you with a clone() method.

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);
    BitSet bitSetClone = (BitSet) bites.clone();
    System.out.println(bites);
    System.out.println(bitSetClone);
  }
}
{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