我有以下代码,我已经多次修改:

public class double3 {
    public double x=0;
    public double y=0;
    public double z=0;
    public double3(double a, double b, double c){
        this.x=a;
        this.y=b;
        this.z=c;
    }
}


double3[] samples = new double3[4];//syntax error on token ";", { expected after this token
samples[0]=new double3(1,2,3);


这里发生了什么,蚀想对我说什么?

最佳答案

陈述

double3[] samples = new double3[4];
samples[0] = new double3(1,2,3);


应该在代码块中,例如方法,构造函数或实例初始化程序

10-05 21:52