Originally Posted by
markyoung1984
I am very new to Java.
I have a List called siteList, which has about 65 objects of type Site. I have a for loop in which I wish to iterate through the List and call a function (test) from each Site object. I'm but quite sure how to do this. So far I have:
for (int i=0;i<siteList.size();i++)
{
siteList.get(i).test(3,3);
}
The compiler states that it cannot resolve symbol for test. Any suggestions?
well, for starters...
will return an Object.... a generic object...Every class in Java is an Object and I can tell you this "test" is not a java object instance variable......
It's specific to your class maybe...a particular class ...not a generic 'Object' class.
Do something like this
((MyClass)siteList.get(i)).test(3,3);
Cas the returned object to MyClass --- your particular class. and the call the in stance variable on the cast