• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Type casting

 
guru sudhakar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic