Online Java Compiler By
JavaTpoint.com
import java.util.BitSet; public class BitSetToLongArrayExample1 { public static void main(String[] args) { BitSet bitset = new BitSet(); bitset.set(0); bitset.set(1); bitset.set(3); bitset.set(5); bitset.set(6); System.out.println("bitset: "+bitset); long[] lngArray = bitset.toLongArray(); System.out.println("byte array: "+lngArray[0]); } }
Output