public byte getBit(int position){ return (ID >> position) & 1;}按位置向右移动ID将使#position位在数字中最靠右的位置。将其与按位
&与1结合将告诉您是否设置了该位。
position = 2ID = 5 = 0000 0101 (in binary)ID >> position = 0000 00010000 0001 & 0000 0001( 1 in binary ) = 1, because the furthest right bit is set.



