Initialize a long in Java
- You should add
L
:long i = 12345678910L;
. - Yes.
BTW: it doesn't have to be an upper case L, but lower case is confused with 1
many times :).
You need to add the
L
character to the end of the number to make Java recognize it as a long.long i = 12345678910L;
Yes.
See Primitive Data Types which says "An integer literal is of type long if it ends with the letter L or l; otherwise it is of type int."