Problem in the GetDeclaredMethods (java)

后端 未结 6 1509
旧巷少年郎
旧巷少年郎 2020-12-10 16:04

I have a small problem in my code

I have 2 classes

public class A {

     public A foo(int a) {return new A();}
}

public class B extends A{

     pu         


        
6条回答
  •  一整个雨季
    2020-12-10 16:13

    Because B.foo and A.foo is different methods. If you want to override method A.foo, then method B.foo must return class A.

提交回复
热议问题