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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Are you asking about
Booleanobject orbooleanprimitive? The size of the object might be 16 bytes (although probably implementation dependent) whilebooleanwill probably consume 4 bytes (intis implicitly used).Thus
boolean[]will consumeN * 4bytes (whereNis the size of the array) + some object header.Boolean[]will consumeN * 16+ header (according to your assumption onBooleansize.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 likeBitSetclass is doing.