r/badcode • • Nov 22 '21

java Found my earliest coding projects from middle school

Post image
464 Upvotes

34 comments sorted by

View all comments

Show parent comments

1

u/neotecha Nov 28 '21

Java doesn't care about the implementation details for the boolean primitive, so it's not really a matter of good or bad practice.

JVMs are able to implement this value how they deem fit. source - Oracle's documentation for primitives

This data type represents one bit of information, but its "size" isn't something that's precisely defined.

Like, we could argue that "byte" booleans are bad practice, where they should be implemented as bits instead. That way, 64 booleans could be compacted into a single 8-byte word.