Tip 39

Characters are 16-bit unsigned integers.You can assign a number literal, assuming it will fit into the unsigned 16-bit range.

These are legal

char ex1 = 0x892;

char ex2 = 982;

char ex3 = (char) 70000;

char ex4 = (char) -98;

char ex5 = '\"';

char ex6 = '\n';

char ex7 = '\u004E';

char ex8 = 'a';

char ex9 = '@';


And the following are illegal

char ex1 = -29; // needs a cast

char ex2 = 70000 // needs a cast