BitSetUtils { public static BitSet fromArray(boolean[] array) { BitSet bitset = new BitSet(array.length); for (int i = 0; i < array.length; i++) { bitset.set(i, array[i]); } return bitset; } private  BitSetUtils(); static BitSet copy(BitSet b); static BitSet getRandomBits(int n, Random random); static String toString(BitSet bits, int n); static String toString(BitSet bits); static boolean innerProduct(BitSet a, BitSet b); static BitSet fromList(List<Boolean> list); static BitSet fromArray(boolean[] array); static boolean[] toArray(BitSet bitset, int length); static List<Boolean> toList(BitSet bitset, int n);  }
@Test public void testFromArray() { boolean[] array = new boolean[] { true, false, true, false, false, false, true }; BitSet bitSet = BitSetUtils.fromArray(array); for (int i = 0; i < array.length; i++) { Assert.assertEquals(array[i], bitSet.get(i)); } }