Can assign integer value to char but can’t assign integer variable to char

A char can be assigned to an int without a cast because that is a widening conversion. To do the reverse, an int to a char requires a cast because it is a narrowing conversion.

See also JLS. Chapter 5. Conversions and Promotions.

Leave a Comment