Determining Set Size : BitSet « Collections « Java Tutorial






A BitSet is a dynamically growing array containing bits.

This dynamically growing structure has two values describing its internal dimensions: a size and a length.

public int size()
public int length()
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.size());
    System.out.println(bites.length());
  }
}
64
4








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