As i know the boolean size in 16 bytes {8 as header,1 payload ,* alignment to 8}
how much does it take if the boolean variable was an array ...
my reference
Are you asking about Boolean object or boolean primitive? The size of the object might be 16 bytes (although probably implementation dependent) while boolean will probably consume 4 bytes (int is implicitly used).
Thus boolean[] will consume N * 4 bytes (where N is the size of the array) + some object header. Boolean[] will consume N * 16 + header (according to your assumption on Boolean size.
That being said consider writing your own array-like class and pack 32 booleans in one int (you'll have to write few bit operations manually), just like BitSet class is doing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With