- public class ExA
- {
- static ExA a = new ExA();
- static
- {
- System.out.println("父类--静态代码块A");
- }
- Y b = new Y();
- public ExA()
- {
- System.out.println("父类--构造函数B");
- }
- {
- System.out.println("父类--非静态代码块C");
- }
- public static void main(String[] args)
- {
- System.out.println("父类--静态代码块S");
- new ExB();
- }
- }
- class Y
- {
- Y()
- {
- System.out.println("Y类无参");
- }
- }
- class ExB extends ExA
- {
- private static ExB b = new ExB();
- static
- {
- System.out.println("子类--静态代码块D");
-
- }
-
- {
- System.out.println("子类--非静态代码块E");
- }
-
-
- public ExB()
- {
- System.out.println("子类--构造函数F");
- }
- Y y = new Y();
- }
复制代码 |
|