This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 18508
    
  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.
 
 
subject: Java's L number (long)
 
Similar Threads
"type int out of range" error on a long variable!
Wrapper objects are immutable???
datatypes
Collection exercise Scrabble
Wrapper class