This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
An integer literal is by default a 32-bit integer, so it can hold values in the range -(2^31) to (2^31)-1. If you write an integer literal which is outside that range (such as 9000000000000000000), the compiler will give you an error, because it doesn't fit in an int. By appending "L" (or "l") you tell the compiler that it's a long literal (64-bit).
The same with floating-point numbers: by default, a floating-point literal is a double. Sometimes you want to specify float literals explicitly, so you add an "F" (or "f") to the number.
I thought I would just contribute something (small) that had me perplexed when i first came across primitives. Consider int - 32bits in size. So it's range is (as stated above!): -(2^31) all the way to (2^31) - 1. Why do you subtract the 1 from the positive range? Because... 0 is counted as a positive integer. Maybe you wondered why you subtract 1, maybe you didn't. Hope it helps anyhow. Best regards. [ June 20, 2008: Message edited by: Keith Nagle ]
Joined: Oct 13, 2005
It might be more precise, Keith Nagle, to say negative and non-negative: exactly 50% each, but it is not a good idea to ask what is a different question in somebody else's thread.