I understand the given reason why it won't compile, but the statementShort k = 9; Integer i = 9; System.out.println(k == i);
Code: Select all
Short k =9;
I know it actually does work, but the literal 9 is an int literal. So, why doesn't it box to an Integer which would be unassignable to a Short variable?
In the case of primitive assignments such as
Code: Select all
byte b = 9;
Code: Select all
byte b = (byte)9;
Code: Select all
Short k = (short)9;