When I specify a number to be a long with a constant value 400, is there any difference between using 400L and 400l?
Does it have some relationship to the wrapper type? Is L used to get a wrapper Long and l for the primitive data type long?
2 Answers
No practical difference. Either L or l can be used, both indicate a long primitive. Also, either can be autoboxed to the corresponding Long wrapper type.
However, it is worth noting that JLS-3.10.1 - Integer Literals says (in part)
1An integer literal is of type
longif it is suffixed with an ASCII letterLorl(ell); otherwise it is of typeint(§4.2.1).The suffix
Lis preferred, because the letterl(ell) is often hard to distinguish from the digit1(one).
Yes: it's readability.
It's easy to mistake 400l for four thousand and one when you first glance at it.
I find it more likely to interpret it correctly as four hundred long with the upper case L.
2