首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2ME开发 >

初学 问个概念。

2012-01-13 
初学 求助 问个概念。。super() 只能写在子类的构造函数中的第一行,只起到调用父类构造函数的作用,也只能给

初学 求助 问个概念。。
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.

热点排行