I have a question about declaring a long variable in Java:
This compiles: long x = 10;
This gives a compiler error: long x = 1000000000000
This compiles: long x = 1000000000000L
Why don't i need to put a L after the number in the first case? How does this relate to the compiler automatically casting a long to an int value (because Iguess that is what's happening in the first example) ?
Also the same question about float's:
This doesn't compile: float f = 10.1;
This compiles: float f = 10;
This compiles: float f = 10.1f;
Why does the first example not compile? Why is the f-prefix not needed in the second example? And how does this relate with the complier automatically casting to a double?
Thanks in advance!