As the error message says, the 0b...
syntax did not exist yet in Java 5 (which is what you seem to be using); it was introduced with Java 7. If you are using Java 7, make sure your compiler settings (in your IDE or build file) are set so that it accepts Java 7 syntax.
Bits are normally counted from the right to the left, so if you say bit 7 is 1, bit 6 is 1, etc. then I would expect the binary number to be 11100000
instead of 00000111
.
To write this in source code in a Java version older than Java 7, you could simply write it as a hexadecimal or decimal number:
// Hexadecimal
byte extra_dop = (byte)0xE0; // or did you mean 0x07?
// Decimal
byte extra_dop = (byte)224; // or did you mean 7?
You could also use Integer.parseInt()
with radix 2:
byte extra_dop = (byte)Integer.parseInt("11100000", 2);
(Note, you could also use Byte.parseByte
but it will not accept 11100000
since it exceeds the range of the signed byte
type).
byte extra_dop = 0111b;
?