autoboxing of numeric literals : wrapper initialization vs passing method arguments inconsistency
Please consider 2 cases: //1 Short s = 10; //obviously compiles //2 takeShort(10); //error - int is not applicable //where: static void takeShort(Short s) {} I assume that case 1 is changed by compiler to : short _temp_s = 10; Short s = Short.valueOf(_temp_s); Could you please explain what compiler is trying to do in case 2, so it does not compile ? If it is not trying to apply autoboxing as it does in case 1, then why ? EDIT Reference to JSL in johnchen902 answer explains compiler's behaviour. Still not exactly clear why JLS does not support "A narrowing primitive conversion followed by a