This is not new, but I wonder how come java can assign something like, 1L
to long
datatype.
private static final long serialVersionUID = 1L;
where the definition of long
data type is,
long: The long data type is a 64-bit signed two's complement integer. It has a minimum value of -9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807 (inclusive). Use this data type when you need a range of values wider than those provided by int.
The L
indicates that it is a long. In other words, 1
is an int whereas 1L
is a long. It is specified in the Java Language Specification #3.10.1:
An integer literal is of type long if it is suffixed with an ASCII letter L or l (ell); otherwise it is of type int.
The suffix L is preferred, because the letter l (ell) is often hard to distinguish from the digit 1 (one).