The list of methods to do Bit Set are organized into topic(s).
byte
setBit(byte data, int bitPos, boolean on) set Bit
if (bitPos < 1 || bitPos > 8) {
throw new IllegalArgumentException("parameter 'bitPos' must be between 1 and 8. bitPos=" + bitPos);
if (on) {
return data |= 1 << (bitPos - 1);
} else {
return data &= ~(1 << (bitPos - 1));
byte
setBit(byte data, int pos, int val) Set one bit in a byte at the specified position with the specified bit value.
int posBit = pos % 8;
return (byte) ((val << (8 - (posBit + 1))) | data);