方法重载编译器错误,方法调用不明确

Aje*_*eet -2 java overloading

对于下面的代码,我确实理解调用方法不明确要调用哪个重载方法是有意义的,但是我无法理解此处如何准确检查参数匹配。

public class Test{
    public void m1(float i,int j){
        System.out.println("float method ");
    }

    public void m1(int i, float j){
        System.out.println("int method ");
    }

    public static void main(String[] args) {
        Test a=new Test();
        a.m1(10,10); // The method m1(float, int) is ambiguous for the type Test
    }
}
Run Code Online (Sandbox Code Playgroud)

Vla*_*sev 5

使用应该使参数之一显式浮动,即使用a.m1(10f, 10);a.m1(10, 10f);否则编译器无法意识到要调用哪个方法