public class A{ static int xingS = 0; //类变量 private int name = 0; //实例变量 String id; //实例变量 private String colorType; //实例变量 private int size; //实例变量 private static String depart; //类变量 f inal String name="zwm"; //常量 } public class B{ public void main (String[] args){ A son1= new A(); A son2= new A(); son1.xingS = 3; // 等同于 A.xingS = 3; son1.name = 4 ; System.out.println(son2.xingS); //结果为3 //类变量是针对所有对象的,所以son1改变xingS,son2的a也改变 System.out.println(son2.name); //结果为0 //实例只改变自身的,所以son1对象的name改变,不影响对象son2的name变量 } }