一个类方法体之外的成员变量有两种实例变量和静态变量/类变量(static修饰)
String name; //成员变量,实例变量
static String name="小明";//成员变量,静态变量(类变量)
成员方法也有实例方法和静态方法/类方法(static修饰)
public int x() { //该方法为实例方法
return x;
}
public static void setX(int x1){ //该方法为类方法
x = x1;
}
注:static不能修饰局部变量,它的作用域只能是全局变量