BitSet: length()

int length()
Returns the "logical size" of this BitSet: the index of the highest set bit in the BitSet plus one.

import java.util.BitSet;

public class Main {
  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());
  }
}
Home 
  Java Book 
    Collection  

BitSet:
  1. Working with variable-length bitsets
  2. new BitSet(int size)
  3. BitSet: and(BitSet anotherBitSet)
  4. BitSet: andNot(BitSet set)
  5. BitSet: clone()
  6. BitSet: get(int bitIndex)
  7. BitSet: length()
  8. BitSet: or(BitSet anotherBitSet)
  9. BitSet: set(int bitIndex)
  10. BitSet: size()
  11. BitSet: xor(BitSet anotherBitSet)