Possible Duplicate:
Convert a byte into a boolean array of length 4 in Java
I am currently studying java, and making games.
I have come on the situation with I need to make some test-data for a game.
I work with tiles in a 2D-array(a map of the game), and each tile needs four bool-values.
So instead of writing the tile in true or false, I want to use a simple Byte, written in binary.
Example: “0b0110” instead of “false, true, true, false”
So I need a way to convert my binary-written Bytes to arrays of Boolean.
You can do something like this:
Going the other way:
I would recommend using
byteandbooleanprimitives unless you need to box them asByteandBooleanfor some other reason.