How does narrowing work in method invocation in Java?
问题 Why this is giving the compile time error? 2 is constant at compile time, therefore narrowing should be allowed here since 2 is in range of byte. public class Test { public static void main(String[] args) { ForTest test=new ForTest(); test.sum(1, 2); //compile time error here } } class ForTest { public int sum(int a,byte b) { System.out.println("method byte"); return a+b; } } The error is: The method sum(int,byte) in the type ForTest is not applicable for the arguements (int,int). Edit: I