类与对象

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


 

 

结论:如果类提供了一个自定义的构造方法,将导致系统不再提供默认构造方法。

 

posted @ 2018-10-21 15:46  #魂  阅读(64)  评论(0编辑  收藏  举报