Assignment issue OCJP; why can't I pass an int to a short?
I have two pieces of code. One works, another doesn't, but both seem to do identical things. This works: short s=7; but the below code doesn't. Instead, it gives error: can't assign int to short I know an integer number literal by default is int , but if it can be assigned directly above, then why not when passing to a method? class Demo1{ public static void main(String[] args){ new Demo1().go(7); } void go(short s){System.out.println("short");} } The rules are different for assignment and for method overload resolution : For assignment the JLS says : In addition, if the expression is a