I have this piece of code.
short x = 50,y=40;
short z = (short)(x + y);//THIS COMPILES
short z2 = (short) x + y;//THIS DOESN'T
How come the code snippet of z compiles, while z2 doesn't? When performing an arithmetic operation on short it will immediately promote it to a int. however I'm downcasting it back to short but it produces an error. Please explain. Am I missing anything?