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 interesting narrowing conversion 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 "interesting narrowing conversion" Watch "interesting narrowing conversion" New topic
Author

interesting narrowing conversion

Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

byte b = (int)16.2;
It is legal. So does casting operator return compile time constant, in this case of course?

double d = 10;
byte b = (int)d; //illegal


SCJP6, SCWCD5, OCE:EJBD6.
BLOG: http://leakfromjavaheap.blogspot.com
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18498
    
  40

It is legal. So does casting operator return compile time constant, in this case of course?


Casting a compile time constant, results in a compile time constant.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Lucas Smith
Ranch Hand

Joined: Apr 20, 2009
Posts: 804
    
    1

Every day I learn something more
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Lukas Smith wrote:Every day I learn something more


Of course, we are learning(improving) everyday
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: interesting narrowing conversion
 
Similar Threads
About cast of int
please clear my doubt on type casting
under what conditions can an int be assigned to a byte?
int as expression value
Adding bytes and getting int