File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Type casting

guru sudhakar

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.

Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1710
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,

I agree. Here's the link:
subject: Type casting
It's not a secret anymore!