2019年4月21日 星期天 在ORACLE官网上提供的The Java™ Tutorials中,有一节课Providing Constructors for Your Classes(为你的类提供构造方法)中提到: You don't have to provide any constructors for your class, but you must be careful when doing this. The compiler automatically provides a no-…
尝试一下: public class Try { final static int a = 1; public Try() { System.out.print("构造方法"); } public static void pt() { System.out.print("静态方法"); } public static void main(String[] args) { pt(); System.out.print(a); } } 执行结果: 说明在调用一个类的静态…