I want to manage the boolean state (on/off) of up to 10^18 items. What is the most memory and computationally efficient way of doing this in Java? I can't create an array of booleans this large as the primitive type of the size of an array is int
, and the same goes for the BitSet
class.
E.g:
long numSwitches = Long.MAX_VALUE;
boolean[] switches = new boolean[numSwitches];
gives me a compilation error: Incompatible types, Reguired: int, Found: long