char
can't hold a value greater than 65535. If you cast a value greater than that to a char, the high-order bits are truncated -- i.e.,
c is assigned the value 0 (65536 & 0xFFFF is 0.)
The reason you get a compiler error with numbers larger than Integer.MAX_VALUE is that to write a larger integral literal in
Java, it must be a long -- you have to write 2147483648L. But you can write
and as it turns out, c will be 0 here as well (all the low-order bits of this number are 0.)
[ July 18, 2003: Message edited by: Ernest Friedman-Hill ]