Why are there no byte or short literals in Java?

In C, int at least was meant to have the “natural” word size of the CPU and long was probably meant to be the “larger natural” word size (not sure in that last part, but it would also explain why int and long have the same size on x86).

Now, my guess is: for int and long, there’s a natural representation that fits exactly into the machine’s registers. On most CPUs however, the smaller types byte and short would have to be padded to an int anyway before being used. If that’s the case, you can as well have a cast.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)