实例变量 布尔值默认false,其余默认值0/null
public class Demo {
String name;//实例变量
int age;//实例变量
static double salary = 2500;//类变量
static final double PI = 3.14;//类常量
final static double PI1 = 3.14;//类常量
public static void main(String[] args) {
int i = 10;//局部变量
Demo demo0 = new Demo();
System.out.println(demo0.age);
System.out.println(salary);
}
}
static
final:常量
都是修饰符,顺序无所谓(只要在变量类型int前就行)
原文:https://www.cnblogs.com/ustust/p/13963111.html