Why system.out.println(011) prints 9 and not 3?

Literals starting with 0 are parsed as octals. Start with 0x for hexadecimals and 0b for binary literals in Java 7+. Lower Java versions have no binary literals, so Integer.parseInt("10101010", 2); should be used instead. Hope this helps.