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.

ok..thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.