Is there already a specific method for converting a Boolean array to a binary array or would I just need a for loop?
1 Answer
If you want to serialize boolean array, check this: How to convert boolean array to binary and vice versa in Java?
If you want to use bits instead of booleans, check BitSet class: http://docs.oracle.com/javase/7/docs/api/java/util/BitSet.html
This class implements a vector of bits that grows as needed. Each component of the bit set has a boolean value. The bits of a BitSet are indexed by nonnegative integers. Individual indexed bits can be examined, set, or cleared. One BitSet may be used to modify the contents of another BitSet through logical AND, logical inclusive OR, and logical exclusive OR operations.
By default, all bits in the set initially have the value false.
You can use these methods:
BitSet#set(int) to set the bit to true at specified position.
BitSet#clear(int) to set the bit to false at specified position.