class TestStatic {
static int a= 1; //静态变量 a = 1;
}
写一个测试类class UseTestStatic {
public static void main(String[] args) {
//创建两个对象
TestStatic testStatic = new TestStatic();
TestStatic testStatic1 = new TestStatic();
//对象1的 a 输出 为1
System.out.println(testStatic1.a);
//对象 重新赋值其a之后
testStatic.a = 5;
//对象 1 的 a 值同样为 5 了
System.out.println(testStatic1.a);
}
}