Java examples for Collection Framework:BitSet
Using the new BitSet methods in Java 7
import java.util.BitSet; public class Main { public static void main(String[] args) { BitSet bitSet = new BitSet(); long[] array = {1, 21, 3}; bitSet = BitSet.valueOf(array); System.out.println(bitSet); long[] tmp = bitSet.toLongArray(); for (long number : tmp) { System.out.println(number); }// w w w. ja va 2s. c om // There's more System.out.println(bitSet.previousSetBit(1)); System.out.println(bitSet.previousClearBit(66)); } }