你知道static的使用的加载先后顺序吗??
如果你不知道恭喜你,这篇文章时专为你写的O(∩_∩)O哈哈~
如果你已经很熟悉了,你可以回忆一下,或不看此片文章^_^
package com.huawei.thinkinjava.basic;
/**
*
* @author bailonggang
* 2009-3-2
* 下午10:39:37
* 結果:
* static statement
* static method
* 0
* construct static
* count = 0
*/
public class Static {
private static int count;
static{
System.out.println(" static statement ");
}
public Static()
{
System.out.println(" construct static ");
}
public static void staticMethod()
{
System.out.println("static method ");
}
public void aa()
{
System.out.println("count = "+count);
}
public static void main(String[] args) {
System.out.println();
System.out.println(count);
Static.staticMethod();
Static c=new Static();
c.aa();
}
}