Reputation: 21
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.
Upvotes: 0
Views: 54
Reputation: 630
There's a parenthesis where there should not be:
world.world**(**fiveDim[5][3][4][1][8] == "white";
Upvotes: 0
Reputation: 1906
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;
}
}
Upvotes: 1