ham ham - 1 month ago 6x
Java Question

long value not accepted in eclipse

hello i need to represent a long value

long f= 13020743289;

but the error says:

the litteral of type int is out of range

even that for longs:
Minimum value is -9,223,372,036,854,775,808.(-2^63)

Maximum value is 9,223,372,036,854,775,807 (inclusive). (2^63 -1)


You must use a long literal, with an L at the end.

long f = 13020743289L;

A long declared without an L at the end is treated as an integer literal. Since yours it out of the range of integer, you must explicitly append an L to tell Java it's a long, declared as a long literal.