1

When I get a input as long datatype, the compiler does not accept the following number

0588235294117647

but if I place the zero other than first position, it is executed.

How can I declare the long number starting with zero ?

My Input

0588235294117647L------->Error

After Change

5088235294117647L------->No Error
Ken Y-N
  • 14,644
  • 21
  • 71
  • 114
hariramahr
  • 19
  • 1
  • Possible duplicate of [Primitive int value conversion?](http://stackoverflow.com/questions/29982566/primitive-int-value-conversion) – Jonny Henly Mar 04 '16 at 05:02
  • 1
    If you want a number to start with `0`, other than zero, use a `String` or something similar. Note: This will no longer make it a *number*. – Jonny Henly Mar 04 '16 at 05:04
  • Possible duplicate of [Why is 08 not a valid integer literal in Java?](http://stackoverflow.com/questions/7218760/why-is-08-not-a-valid-integer-literal-in-java) – fabian Mar 05 '16 at 22:52

1 Answers1

7

The leading zero tells the compiler that it is an octal constant, which does not accept digits larger than 7.

This is independent of the long data type, which simply specifies the size of the integer, not the format of the constant.

Omit the leading zero and this will work.