java问题——Constructor call must be the first statement in a constructor
2014-04-17 18:49
507 查看
刚刚按照书上编了个小程序,写着写着就提示一个错误:Constructor
call must be the first statement in a constructor。然后在网上搜了一下,原来是构造函数都要放在第一行,这是语法规则。那好吧,暂且这样考虑吧。(然后想说一句,java高手真经错误挺多的啊)
call must be the first statement in a constructor。然后在网上搜了一下,原来是构造函数都要放在第一行,这是语法规则。那好吧,暂且这样考虑吧。(然后想说一句,java高手真经错误挺多的啊)
class Car{ int v; String name; Car(int v, String name){ this.v = v; this.name = name; } Car(){ } void drive(){ System.out.println("Car 速度:" + v); } } class Bus extends Car{ int p; Bus(){ } Bus(int p){ this.p = p; } Bus(int p, int v, String name){ super(v, name); this.p = p; //现在这里改回来了 } void carry(){ System.out.println("Bus 载人:" + p); } void print(){ System.out.println("Bus 速度:" + v); System.out.println("Bus 载人:" + p); System.out.println("Bus 名字:" + name); } }
相关文章推荐
- 有关Constructor call must be the first statement in a constructor的问题
- Java异常解决:Constructor call must be the first statement in a constructor
- Constructor call must be the first statement in a constructor
- Constructor call must be the first statement in a constructor
- Constructor call must be the first statement in a constructor
- Constructor call must be the first statement in a constructor
- Constructor call must be the first statement in a constructor
- Fatal error: Namespace declaration statement has to be the very first statement or after any declare call in the script in
- must be the first statement in a query batch
- SQL写存储过程时报错 'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.
- SQL写存储过程时报错 'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.
- Namespace declaration statement has to be the very first statement or after any declare call in the script
- Namespace declaration statement has to be the very first statement in the script;定义命名空间无效
- 解决继承RecyclerView.Adapter界面崩溃及部分布局不显现的问题【 You must call removeView() on the child's parent first.】
- laravel 报错:Namespace declaration statement has to be the very first statement in the script
- Namespace declaration statement has to be the very first statement in the script
- Namespace declaration statement has to be the very first statement in the script--ThinkPHP3.2.3
- java错误提示------ The public type must be defined in its own file
- 记:解决Namespace declaration statement has to be the very first statement in the script 错误
- Django:ExtendsNode: extends 'base/base.html'> must be the first tag in the template.