错误:错误:此类应提供默认构造函数(不带参数的公共构造函数)(net.skinnycat.accelerometertest.AccelData)[Instantiatable]
如何解决这个问题?
这里是我的代码:
package net.skinnycat.accelerometertest;
public class AccelData{
private long timestamp;
private double x;
private double y;
private double z;
public AccelData(long timestamp, double x, double y, double z) {
this.timestamp = timestamp;
this.x = x;
this.y = y;
this.z = z;
}
public long getTimestamp() {
return timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
public double getZ() {
return z;
}
public void setZ(double z) {
this.z = z;
}
public String toString() {
return "t=" + timestamp + ", x=" + x + ", y=" + y + ", z=" + z;
}
}`
答案 0 :(得分:0)
您需要添加
public AccelData(){}
到您班级