PrepZone Logo
PrepZone
Back to Java

Java · Medium

What is a BitSet in Java? When is it more memory-efficient than a boolean array?

JavaCollections

Answer preview

BitSet is a resizable bit vector that compactly stores true/false values. It uses one bit per value — far more memory-efficient than boolean[].…