How to declare a single bit variable in java?
"When you allocate a boolean array, Java uses an entire byte for each element in the boolean array!"
https://dzone.com/links/hidden_evils_of_javas_boolean_array.html
Usually, in java you can just add two numbers and something behind the scene will deal with the internal carry digits.
However, when using javax.crypto.Cipher or something byte-oriented, data will be in byte[].
When doing arithmetic operations on byte[] sequence, I might need to deal with the carry bits mantually.
The carry bit needs only 1-bit data intead of an entire int space.
I found another way is to let java deal with the arithmetic operations on a numeric array.
It involves a method named BigInteger.
BigInteger namely might need even more space, and the behavior of the class is slightly different.
@Acer So utilize the space.. Like i said java is not a language suited for memory space optimization. If you need low-level control of data at a memory level you need to use a different language.
@Acer you dont, if you care about low-level aspects dont use java.. Your other option is to declare an int and just assign the bits manually.. but if your asking this question you are simply using the wrong tool, thats not the tools fault its yours :)