wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android forum!
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: 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,

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