private static int age;//静态的变量 多线程!
private double sorce;//非静态的变量
public static void run(){}
public void go(){}
public static void main(String[] args){
Student S1 = new Student();
System.out.println(Student.age);
//System.out.println(Student.sorce);非静态方法
System.out.println(S1.sorce);
System.out.println(S1.age);
run();
new Student().go();
}
{ //作用 : 赋初始值
// 代码块(匿名代码块)
System.out.println("匿名代码块");// 第二运行
}
static {
// 静态代码块
System.out.println("静态代码块");// 第一运行
}
public Person(){
System.out.println("构造方法");// 第三运行
}
public static void main(String[] args) {
Person person = new Person();
System.out.println("============================");
Person person1 = new Person();
}
//final 之后 无法生成子类
//静态导入包
import static java.lang.Math.PI;
import static java.lang.Math.random;
public class Test {
public static void main(String[] args) {
System.out.println(random());
System.out.println(PI);
}
}