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

前端 未结 5 1492
一个人的身影
一个人的身影 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:22

    The JLS will not consider 2 conversions and 1 conversion to be a difference. It will only distinguish between having-to-convert and not-having-to-convert.

    Since both methods have-to-convert, they are equally possible.

    Related to this subject, there is my answer on a similar question (but not entirely the same).

提交回复
热议问题