I just wanted to experiment with some integers and assigned the value "0013" to an integer a. When I print the value to the output console I get "11". What causes this? Why I do not get 13 ?
int b = 0013;
System.out.println(b);
I just wanted to experiment with some integers and assigned the value "0013" to an integer a. When I print the value to the output console I get "11". What causes this? Why I do not get 13 ?
int b = 0013;
System.out.println(b);
Java has accidentally automatically taken your number to be an octal number. Unlike hexadecimal notation, where the number is preceded by a 0x
, octal is proceeded by a single zero. The compiler has probably taken your number and made it into an octal format.
Try using 13
instead of 0013