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
0s will make Java interprets the number as octal number. So,010is actually8.OUTPUT:
And as you know,
8and9are not allowed in an octal number.