What does “The constructor … is ambiguous” mean?

后端 未结 4 1002
花落未央
花落未央 2021-01-07 17:37

I would like to know what the error message in Eclipse means:

The constructor Case(Problem, Solution, double, CaseSource) is ambiguous

4条回答
  •  庸人自扰
    2021-01-07 17:49

    To add on to other answers, it can be avoided by casting the argument to what is intended, e.g.:

    class Foo {
    
        public Foo(String bar) {}
        public Foo(Integer bar) {}
    
        public static void main(String[] args) {
            new Foo((String) null);
        }
    
    }
    

提交回复
热议问题