getMethods与public override方法

public class TT {

public static void main(String[] args) {
System.out.println(B.class.getMethods().length);
System.out.println(C.class.getMethods().length);
}

private static class A {
public A xxx() {
return new A();
}
}

private static class B extends A {
@Override
public B xxx() {
return new B();
}
}

private static class C extends A {
@Override
public A xxx() {
return new C();
}
}
}

11

10

public class TT {

public static void main(String[] args) {
System.out.println(B.class.getMethods().length);
System.out.println(C.class.getMethods().length);
}

private static class A {
public A xxx() {
return new A();
}
}

private static class B extends A {
@Override
public B xxx() {
return new B();
}
}

private static class C extends A {
@Override
public A xxx() {
return new C();
}
}
}

posted on 2023-07-31 17:40  silyvin  阅读(18)  评论(0编辑  收藏  举报