我在这一行收到一个错误:
public int[][] mySpiros;
错误如下:
Field Spirograph.myList.mySpiros is never assigned to, and will always have its default value null
.
现在这一行写在一个类中。我只想创建一个双精度数组,这样我就可以为用户生成的每个绘图(螺旋图)存储我的未来参数。
编辑:似乎实例化多个数组integers
不是微软最喜欢的动作:
我在这一行收到一个错误:
public int[][] mySpiros;
错误如下:
Field Spirograph.myList.mySpiros is never assigned to, and will always have its default value null
.
现在这一行写在一个类中。我只想创建一个双精度数组,这样我就可以为用户生成的每个绘图(螺旋图)存储我的未来参数。
编辑:似乎实例化多个数组integers
不是微软最喜欢的动作:
You're creating array of arrays so you need to instantiate arrays like:
public int[][] mySpiros;
//create three reference variables to hold array references
mySpiros=new int[3][];
mySpiros[0]=new int[4];
mySpiros[1]=new int[] {11,22,33,44};
mySpiros[2]=new int[40];
This is usually a warning, and not an error. Make sure you haven't set "Treat Warning as Error" in the Project setting. Right click on project->Properties and set this: Screenshot
Make sure it is set to "None". That should allow you to build and run.
Be aware, this warning means your code is never creating an instance of this field, which in turn will generate null reference exception!