How JVM finds method (parameter with the closest matching) to call in case of function overloading

后端 未结 6 1584
耶瑟儿~
耶瑟儿~ 2020-12-15 22:56

The JVM decides which overloaded method to call at compile time. I have one example:

public class MainClass{

  public static void go(Long n) {System.out.pr         


        
6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-15 23:06

    Because upcasting to int was in version 1.0 of Java and auto-boxing was added in version 5.0. Changing the behaviour would break code written for older version of Java.

提交回复
热议问题