Static变量通俗来说,即所有对象可以共享
non Static,每个有自己的一个拷贝
class StaticTest
{
public static void main(String [] args)
{
Customer c = new Customer();
Customer c2 = new Customer();
}
}
class Customer
{
//静态块
static
{
System.out.println("static block");
}
//非静态块
{
System.out.println("non static block");
}
}
输出:static block
non static block
non static block
结论:即static块被共享,新new出来的对象共享static块
System.out.println("static block");
}