I would like to print the static variable of another class but I cant for some reason. Here is the error when compiling:
System.out.println(Creature.MAX_Y);
^
symbol: variable MAX_Y
location: class Creature
1 error
Here is the code for the Creature class:
package naturalselection.creature;
import naturalselection.food.Food;
import naturalselection.vector.Vector;
import naturalselection.creature.Target;
import java.util.*;
public class Creature{
public static short MAX_X = 150;
public static short MAX_Y = 150;
}
and the main class:
import naturalselection.creature.Creature;
import naturalselection.food.Food;
class Main{
public static void main(String[] args){
Creature c1 = new Creature(1, 1);
System.out.println(Creature.MAX_Y);
}
}
Here is the directory structure (part of it):
main.java
naturalselection -
+-- creature
+-- Creature.java
.javafiles. Also show how you compile your files.naturalselection.creature.Creatureclass. Also check if you have a differentCreatureclass (or even aCreature.classfile somewhere) somewhere which is used instead. You might want to delete all.classfiles and recompile everything.