I wonder why I am getting compilation error 'out of range'.
Long l =004055158L;//giving The literal 004055158L of type long is out of range.
Long l =404055158L;//no compilation error
I wonder why I am getting compilation error 'out of range'.
Long l =004055158L;//giving The literal 004055158L of type long is out of range.
Long l =404055158L;//no compilation error
It's out of range because a numeric literal with leading 0s is treated as an octal number (radix 8), in which the digit 8 is not valid.
Changing it to
Long l = 004055157L;
will remove the compilation error. Of course, there's no point to have leading 0s unless you actually want an octal number.