我收到class
或interface
预期错误。有人知道该如何去做吗?我是java的新手并且正在努力学习!提前致谢。
public class RallyDevice {
private int _sno;
private Time _currentTime;
private double _dist;
private double _avgSpeed;
private double _requiredTime;
private Time _idealTime;
}
public RallyDevice(){}
public RallyDevice(int sno, Time currentTime, double dist,double avgspeed,double requiredtime,Time idealtime) {
this._sno = sno;
this._currentTime = currentTime;
this._dist = dist;
this._avgSpeed = avgspeed;
this._requiredTime = requiredtime;
this._idealTime = idealtime;
}
public RallyDevice( Time currentTime, double dist,double avgspeed,double requiredtime,Time idealtime) {
this._currentTime = currentTime;
this._dist = dist;
this._avgSpeed = avgspeed;
this._requiredTime = requiredtime;
this._idealTime = idealtime;
}
答案 0 :(得分:1)
您必须使用重载的构造函数将您的类封闭在内部,而不是在
之外public class RallyDevice
{
private int _sno;
private Time _currentTime;
private double _dist;
private double _avgSpeed;
private double _requiredTime;
private Time _idealTime;
public RallyDevice()
{
}
public RallyDevice(int sno, Time currentTime, double dist,double avgspeed,double requiredtime,Time idealtime)
{
this._sno = sno;
this._currentTime = currentTime;
this._dist = dist;
this._avgSpeed = avgspeed;
this._requiredTime = requiredtime;
this._idealTime = idealtime;
}
public RallyDevice( Time currentTime, double dist,double avgspeed,double requiredtime,Time idealtime)
{
this._currentTime = currentTime;
this._dist = dist;
this._avgSpeed = avgspeed;
this._requiredTime = requiredtime;
this._idealTime = idealtime;
}
}