I am trying to set bits in a Java byte variable. It provides methods like .setBit(i) . Does anyone know how I can figure this out?
I can iterate bit by bit over a given byte:
if( (my_byte & (1 << i)) == 0 ){ }
However, I cannot set this position to 1 or 0, can I?
java bit-manipulation byte
wishi Jan 12 '11 at 21:00 2011-01-12 21:00
source share