static public class Person { //2 { System.out.println("匿名代码块"); } //1 只执行一次 static { System.out.println("静态代码块"); } //3 public Person() { System.out.println("构造方法"); } public static void main(String[] args) { Person person1 = new Person(); System.out.println("======="); Person person2 = new Person(); } } 结果 public class Student { private static int age;//静态变量 private int score;//非静态变量 public void run(){ go(); } public static void go(){ } public static void main(String[] args) { go(); new Student().run(); } } /* Student s1 = new Student(); System.out.println(Student.age); System.out.println(s1.age); System.out.println(s1.score); */ //静态导入包 import static java.lang.Math.random; public class Test { public static void main(String[] args) { System.out.println(random()); } }