[英]Trouble accessing an array in a separate class
I am trying to access an element of my array that is in a separate class, world, but I get a cannot find symbol error. 我正在尝试访问数组的元素,该元素位于单独的类world中,但出现无法找到的符号错误。 Here is my code:
这是我的代码:
public class Lab9 {
public static void main(String [] args)
{
World world = new World();
world.world(fiveDim[5][3][4][1][8]) == "white";
}
And then the class, world 然后是课堂,世界
public class World {
public void world(int dim1, int dim2, int dim3, int dim4, int dim5, String color)
{
String[][][][][] fiveDim = new String[10][10][10][10][10];
fiveDim[dim1][dim2][dim3][dim4][dim5] = color;
}
}
Although not written in the code yet, I want to check if that specific spot in the array is the string "white" and if not, to replace it, but I cannot find a way to check. 尽管还没有用代码编写,但是我想检查数组中的那个特定点是否是字符串“ white”,如果不是,则替换它,但是我找不到一种检查方法。
This should be syntactically correct. 这在语法上应该是正确的。 But idea and code need many improvements.
但是想法和代码需要许多改进。
public class World {
public String[][][][][] fiveDim = new String[10][10][10][10][10];
public void world(int dim1, int dim2, int dim3, int dim4, int dim5, String color)
{
fiveDim[dim1][dim2][dim3][dim4][dim5] = color;
}
}
有一个括号,其中不应有:
world.world**(**fiveDim[5][3][4][1][8] == "white";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.