package fengke.hashcode; |
/** |
* 详细讲明了null 与new class()的区别; |
* 分清了static与construction的运行关系; |
* @author 锋客 |
* |
*/ |
public class StacticAndConstructionTest { |
public static int a = 0 ; |
static { |
a = 10 ; |
System.out.println( "父类的静态代码块在执行a=" + a); |
} |
{ |
a = 8 ; |
System.out.println( "父类的非静态代码块在执行a=" + a); |
} |
public StacticAndConstructionTest() { |
this ( "a在父类带参构造方法中的值:" + StacticAndConstructionTest.a); // 调用另外一个构造方法 |
System.out.println(a); |
System.out.println( "父类无参构造方法在执行a=" + a); |
} |
public StacticAndConstructionTest(String n) { |
System.out.println(n); |
System.out.println(a); |
} |
public static void main(String[] args) { |
StacticAndConstructionTest tsc = null ; |
System.out.println( "new操作:" ); |
tsc = new StacticAndConstructionTest(); |
} |
} |