Java – In Java, can I define an integer constant in binary format

binaryjavasyntax

Similar to how you can define an integer constant in hexadecimal or octal, can I do it in binary?

I admit this is a really easy (and stupid) question. My google searches are coming up empty.

Best Solution

In Java 7:

int i = 0b10101010;

There are no binary literals in older versions of Java (see other answers for alternatives).