When using overloading with type promotion, why method calling is ambiguous?

前端 未结 5 1488
一个人的身影
一个人的身影 2021-01-05 08:26
public class aman {
    void m(double a , int b, int c) {
        System.out.println(\"second\");
    }
    void m(float a , int b, double c) {
        System.out.pr         


        
5条回答
  •  时光取名叫无心
    2021-01-05 09:21

    It is ambigous because you are calling it with three Integer literals.

    You have to use either:

    obj.m(23d, 12, 1);
    

    or

    obj.m(23, 12, 1f);
    

    to bring out wich argument is wanted as is and wich arguement can be casted.

提交回复
热议问题