File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Long Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Long " Watch "Long " New topic
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: 19541
    
  16

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 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Long
 
Similar Threads
Right triangles
Passing Score?
Comparing only dates and not timestamp
java.sql.Date - setting a future date?
How to get past date ?