标签:
package com.test.innerclass; public class HelloB extends HelloA { public HelloB() { System.out.println("HelloB"); } { System.out.println("I‘m B class"); } static { System.out.println("static B"); } public static void main(String[] args) { new HelloB(); } } class HelloA { static { System.out.println("static A"); } { System.out.println("I‘m A class"); } public HelloA() { System.out.println("HelloA"); } }
运行结果:
static A
static B
I‘m A class
HelloA
I‘m B class
HelloB
总结:父类static块
子类static块
父类{}块
父类构造方法
子类{}块
子类构造方法
标签:
原文地址:http://www.cnblogs.com/heben/p/5391964.html