"cannot make static reference to non-static field"
807601May 20 2008 — edited May 22 2008Hi, I was trying to keep a counter variable that would increment separately for each instance of my cube class every time the constructor from the face class is called within the cube constructor, but Java doesn't seem to like my implementation. Any ideas? I know I could do this manually, but I'm looking for an way to automatically increment. The essentials of my code should look something like this... note that I am showing two separate classes. Thanks in advance for any advice!
public class face{
private int[] data;
public face (String name){
this.name = name;
data = new int[3];
for (int i = 0; i<3; i++){
data = i + (3**cube.counter*-1);
}
cube.counter++;
}
}
public class cube{
private face front, back, side;
public int counter = 1;
public cube() {
front = new face("Front");
back = new face("Back");
side = new face("Side");
}
}