hello to all
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{
public B foo(int x){ return new B();}
}
now in my code I want to print only the method that was declared in class B
in this way
B b = new B();
Method[] m = b.getClass().getDeclaredMethods();
for (int i = 0; i < m.length; i++) {
System.out.print(m[i].getName());
}
why the output is
foo
foo
why the GetDeclaredMethods finds also the foo in the A class? how can i fix it?
thanks