This might be a silly thing but how is this possible that compiler will show this while Long.Max = 9223372036854775807
?
Asked
Active
Viewed 5,743 times
15

HavelTheGreat
- 3,299
- 2
- 15
- 34

vach
- 10,571
- 12
- 68
- 106
3 Answers
25
You must have Long
literals in Java ending with an L
, adding an L
to your integer will correct your issue, like so: Long s = 9223372036854775806L
This is because by default Java interprets all integers as 32-bit (int
), the suffix L
ensures that your integer is interpreted as 64-bit.

HavelTheGreat
- 3,299
- 2
- 15
- 34
5
just put 'l' or 'L' in the end of it and it will be ok, like:
long a = 9223372036854775807L;

roeygol
- 4,908
- 9
- 51
- 88