Using the new BitSet methods in Java 1.7 : BitSet « JDK 7 « Java






Using the new BitSet methods in Java 1.7

import java.util.BitSet;

public class Test {

  public static void main(String[] args) {
    BitSet bitSet = new BitSet();
    long[] array = { 1, 2, 3 };
    bitSet = BitSet.valueOf(array);
    System.out.println(bitSet);

    long[] tmp = bitSet.toLongArray();
    for (long number : tmp) {
      System.out.println(number);
    }

    System.out.println(bitSet.previousSetBit(1));
    System.out.println(bitSet.previousClearBit(66));

  }
}

 








Related examples in the same category