翻转一个字节中的所有位值

Flip all bit values in a byte

我想翻转一个字节中的所有位。我该怎么做?

例如:

input:  10101000
output: 01010111

使用 ~ bitwise complement operator.

byte flipped = (byte) ~original;