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. 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.
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";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.