jQuery in Action, 2nd edition*
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


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 "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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Type casting
 
Similar Threads
return types!
switch statement
How can it be valid?
implicit casting of final int to byte ???
Cast byte to char