posted 14 years ago
Friends,
I am having problems with ArrayList items in a method that must be static. The code picks two random mice in the mice ArrayList. It then is suppose to compare the two mice to see if they are of different sex and both over the age of 1.
Here is my code
The code as is generates an error message like this for all my metods in the if loop ...
non-static method getAge(java.util.ArrayList,int) cannot be referenced from a static context
&& ((getAge(mice, a) >1) && (getAge(mice, b) >1)))
I have tried to change the code (and the methods) to not accept parameters, to something similar to this ...
but, I then get this error message:
cannot find symbol
symbol : method mice(int)
location: class Mouse ... I have imported the Java.util.ArrayList class into the Mouse class. The mice is the ArrayList and the (int) should be the index of the item in the list.
Any help on this is appreciated.
Thanks!