I just learned about using "L" after long values to signify that they're long types, just like when you use "f" after float types. I was wondering what happens when you write;
long value = 3;
instead of
long value = 3L;
So I was wondering;
Does the compiler consider 3 an integer and then just convert it implicitly to a long?
Then I tried to check the type of the value "3" by using instanceof (but I can't use it since it is a primitive type) or reflection (getClass(), but obviously I can't because it isn't a reference type). Is there anyway to check what type the value "3" is or is this impossible since Java is statically typed?
Thanks, Bernard
According to section 3.10.1 Integer Literals of the Java 14 Language Specification: