I have below code
int a = 01111;
System.out.println(\"output1 = \" + a);
System.out.println(\"output2 = \" + Integer.toOctalString(1111));
System.out.println("output2 = " +Integer.toOctalString(1111));
Is converting the decimal string 1111
to an octal string: 2127
.
The decimal value of the octal 1111
, is 585
- as expected, the result is expected, you don't get the same values because the two statements do different things.
A correct test will be:
System.out.println("output2 = " +Integer.toOctalString(a));
Which will give you, as expected, 1111