abstract class A {
public abstract void print();
private static class B extends A {
public void print() {
System.out.println("Hello");
}
}
public static A getInstance() {
return new B();
}
}
public class Demo {
public static void main(String[] args) {
A a = A.getInstance();
a.print();
}
}
Java抽象类(内部抽象类)
最新推荐文章于 2024-07-28 19:11:58 发布