Is there a such thing in Java as chr()? such as chr(65) = 'A'?
Printable View
Is there a such thing in Java as chr()? such as chr(65) = 'A'?
char a = (char)65;
Thanks, CB. I couldn't figure out how to search for this one.
Since the assignment results in an implicit narrowing primative conversion no cast is needed. If the source is an int constant whos value can be determined to be in the range of the destination type byte short or char then you can omit the type cast. :)
Yes, but not if he casts from an int variable, which is what he'll do most of the time, so showing the cast makes sense.
Yes of course.Code:Posted by CornedBee
Yes, but not if he casts from an int variable.
Just wanted to point out that the cast was not needed with the expression you posted. You never know he might want to take the SCPJ2 exam. Sun sure does get dam pickey. :lol:Code:int i = 65;
char c = (char)i;