public class STATIC { public static void main(String[] args) { // 创建两个不同的类 只要赋值一个 另外一个定义好的static属性 会同时赋值(共享一个静态变量) // 理解: 类似于有点像session同步值 USA usr1 = new USA(); USA usr2 = new USA(); // usr1.nation = "定义"; // usr1.nation = "后者"; // System.out.println(usr2.nation); // usr1.count = 0; usr1.count = usr1.count + 1; usr1.count = usr1.count + 1; System.out.println(usr2.count); System.out.println("当前创建实例化的个数为:"); } } class USA{ String name; int age; static String nation; static int count; }