The Java Language specification (Section 3.10.1) states the following:
An integer literal is of type long if it is suffixed with an ASCII letter L or l [...]; otherwise it is of type int (ยง4.2.1).
So far so good, this means that the following two assignments will result in different results.
long x = 2_000_000_000 * 40_000;
long y = 2_000_000_000 * 40_000L;
So I see why the idea of having standardized Literal-Types makes sense, and why it's needed, but I can't really see the benefit of choosing int
over long
as the standard type for literals.
After all, long
would enable a broader amount of operations without the extra need to add specific suffixes as far as I can see.
If someone could explain the advantage to me, that would be of great help! Thanks a lot in advance!