<分区>
如以下链接所述Link
Static variables are initialized only once, at the start of the execution. These variables will be initialized first, before the initialization of any instance variables.
A single copy to be shared by all instances of the class.
但是我可以改变静态变量的值
class Test {
static int a =10;
public static void main(String args[])
{
a=20;
System.out.println("rest of the code...");
Test1 t= new Test1();
t.m();
}
}
public class Test1 {
void m ()
{
System.out.println(Test.a);
}
}