Rade Koncar wrote:Thanks on reply,
I understand that literal is int, but I don't understand why compiler assigns particular int value (23 which is valid for short) to short variable,
and won't do the same when it is method argument.
This looks like inconsistency to me, because compiler knows at compile time that this literal is small enough to fit into a short so it can safely
shorten it. Compiler does this for assignment in line 3, why not for method call in line 4...
When you call method f(23), then compiler thinks that 23 is an int, it cannot assign 23 as short. And since the value cannot be converged implicitely, so the compiler cannot assign int (in your case 23) to a short.
Instead if you do f((short)23), then the compiler should not complain, as you are specifying the compiler to cast it to a short