读书人

初学 问个概念。

发布时间: 2012-01-13 22:43:29 作者: rapoo

初学 求助 问个概念。。
super() 只能写在子类的构造函数中的第一行,只起到调用父类构造函数的作用,也只能给父类构造函数传递参数。 这样说 对吧???

[解决办法]
这一点JDK文档有说明:

Invocation of a superclass constructor must be the first line in the subclass constructor.

The syntax for calling a superclass constructor is

super();
--or--
super(parameter list);

With super(), the superclass no-argument constructor is called. With super(parameter list), the superclass constructor with a matching parameter list is called.

读书人网 >J2ME开发

热点推荐