File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Java's L number (long) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Java Watch "Java New topic
Author

Java's L number (long)

Elier Rguez
Greenhorn

Joined: Jun 27, 2013
Posts: 22
Hi,
can anybody see why l1 compile well and don't l2?


Thanks in advance,




Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19073
    
  40

Elier Rguez wrote:
can anybody see why l1 compile well and don't l2?




Only certain conversions are allowed by the Java Language Specifications -- and an implicit widening cast from int to long, followed by an autobox from long to Long, isn't one of the allowed conversions.


See .. http://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html#jls-5.2

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Elier Rguez
Greenhorn

Joined: Jun 27, 2013
Posts: 22
Got it, thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java's L number (long)