| Author |
Long
|
Manish Khurana
Greenhorn
Joined: Jan 26, 2008
Posts: 23
|
|
why dooes this work i though it had to have a L at the end long patience = 1000 * 60 * 60;
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Without an L, the result is an integer, because all operands are integers. Since 1000 * 60 * 60 (3600000) is a valid integer, there will be no problems. If your intermediate result would exceed Integer.MAX_VALUE (2^31-1), then the result would be truncated, and you would get a wrong value. Only then you need an L to inform the compiler that the intermediate result is a long as well so it won't be truncated.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: Long
|
|
|