Reputation: 129
Hi so I'm still learning to use methods, but one of my assignments requires me to call a method from a method in a different .java file.
The problem is "Sets" is not recognized and it displays an error message stating that both "Sets" cannot be resolved to a variable. Am I calling the method incorrectly?
This is the method if it is relevant. It comes from a java file called Sets.
public static final int Initial_Pop =
(int)(EARTH_AT * EARTH_BT * 0.4);
This is the method I'm trying to call the above method..
public static void plusPeople (int[][] earth, int newPerson) {
int [][] earthpopulation = new int [Sets.EARTH_AT][Sets.EARTH_BT];
}
I apologize if I'm unclear or did not provide enough information. If so please tell me!
Upvotes: 0
Views: 137
Reputation: 2452
when you call Sets.EARTH_AT
and Sets.EARTH_BT
, these are not methods, but rather variables within the Sets class. Make sure these are static variables inside Sets class
Upvotes: 0
Reputation: 5709
You are trying to access EARTH_AT and EARTH_BT and I don't know if these are static. Even though the variable declared is INITIAL_ALIVE_COUNT.
Also remember to check if both classes are in the same Folder (or package). If not, you'll have to import the Sets class.
Upvotes: 1