public class 动手动脑1 { public static void main(String[] args) { Foo obj1=new Foo(); } } class Foo{ int value; public Foo(int initValue) { value=initValue; } }
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The constructor Foo() is undefined
结论:如果类提供了一个自定义的构造方法,将导致系统不再提供默认构造方法。