1.代码块
public class StaticDemo {
{
System.out.println("匿名代码块");
}
static{
System.out.println("静态代码块");
}
public StaticDemo(){
System.out.println("构造函数");
}
public static void main(String[] args) {
StaticDemo demo=new StaticDemo();
System.out.println("==================");
StaticDemo demo1=new StaticDemo();
}
}
执行结果:
2.静态导入包
import static java.lang.Math.random;
public class Demo02 {
public static void main(String[] args) {
System.out.println(random());
}
}
标签:System,static,StaticDemo,println,相关,public,out
From: https://www.cnblogs.com/Yolanda-fan/p/18024563