A new feature of Java 7 is the introduction of binary literal values. This allows you to write out binary values directly by prefixing the number with a “0b” or “0B” (zero B).
byte one = (byte)0b00000001;
byte two = (byte)0b00000010;
byte four = (byte)0b00000100;
byte sixteen = (byte)0b00001000;
int cafebabe = 0b11001010111111101011101010111110;
long lots_o_ones = (long)0b11111111111111111111111111111111111111111111111L;
0 comments:
Post a Comment