In Java, I noticed that when I write
int i = 99;
it works fine. However when I say
int i = 099;
I get an exception:
java.lang.RuntimeException: Uncompilable source code - Erroneous tree type: <any>
In my IDE, I see a red dot saying integer number too large: 099
.
Why this is not getting compiled? Isn't 099 is equivalent to 99?
Any leading 0
s will make Java interprets the number as octal number. So, 010
is actually 8
.
System.out.println(010);
OUTPUT:
8
And as you know, 8
and 9
are not allowed in an octal number.
That's an octal number. Octal numbers are prefixed with 0
to set them apart from other values such as decimal and hexadecimal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With