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 Type casting 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 "Type casting " Watch "Type casting " New topic
Author

Type casting

guru sudhakar
Greenhorn

Joined: Apr 02, 2007
Posts: 8
Hi friends,

I've a small doubt on casting i.e
final byte b=4;
char c=b;// no error
when i used only byte with out final and assign it to char
getting error .//possible loss of precision

please provide me any insights on this.

Thanks,
Guru
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Hi Guru,


final byte b=4; //It is compile time constant.
char x=b; it is like x=4; so no error

byte bb=4;
char cc=bb; //error


Thanks and Regards,
cmbhatt


cmbhatt
 
Don't get me started about those stupid light bulbs.
 
subject: Type casting