java - how to create and manipulate a bit array with length of 10 million bits

bitmap, java

Solution

Use `BitSet` (as Hunter McMillen already pointed out in a comment). You can easily get and set bits. To iterate just use a normal `for` loop.

Problem

I just came across a problem; it was easy to solve in pseudo code, but when I started coding it in java; I started to realize I didn't know where to start... Here is what I need to do: - I need a bit array of size 10 million (bits) (let's call it A). - I need to be able to set the elements in this array to 1 or 0 (A[99000]=1). - I need to iterate through the 10 million elements.

Original source