my dog learned polymorphism*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Casting 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 "Casting" Watch "Casting" New topic
Author

Casting

sanjana narayanan
Ranch Hand

Joined: Nov 25, 2003
Posts: 142
The following line code of code makes no sense to me.
byte b= (byte)(long)(short)16.2;
pl share your comments with me..

-Sanjana
Vicken Karaoghlanian
Ranch Hand

Joined: Jul 21, 2003
Posts: 522
Hi sanjana,
The byte, short, long datatypes can't hold fraction values. What happens in your code, is that 16.2 is treated as double then it is casted to short (16), long(16), byte(16) respectively, hence truncating its value to 16.
[ December 08, 2003: Message edited by: Vicken Karaoghlanian ]

- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. <br />- What truth? <br />- That there is no spoon!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Casting
 
Similar Threads
Multi dimensional array
expression involving int or smaller
from my screen i wanted to send mail and from screen one report will generate that i wanted to send
Array Index Out Of Bounds
8- byte array Intialization Vector