+ 2
Why this statement gives error ? Any explanation please?(The error is : integer number too large)
Int x = 081;
4 Respostas
+ 3
Java treats integers leading with 0 as octal numbers
Best explanation I got from stackoverflow:
Octal (base-8 number)
0123 means octal 123, that is 1*8*8 + 2*8 + 3, which equals 83. For some reason, octal floats are not available.
Creating 0123 means the integer 83. Creating 0123F means the floating 123. When converted back to integer, it remains 123.
"Just don't use the leading 0 if you don't mean octal. After all, they are not exactly useful(and programmers who do know about octal numbers will get confused when they see 09F)"
Source:
https://stackoverflow.com/questions/565634/integer-with-leading-zeroes
+ 3
if the number start with 0, it'll be registered as octal.
but octal dont have 8 in its numbering system, only 0 to 7.
+ 2
This is octal literal https://www.tutorialspoint.com/define-integer-literals-as-octal-values-in-java
But max number in this system is 7, so "8" is cause
+ 1
Try this.
int x = 81;
Why are you using 0 in front of 81?