Charles Bell
Posts: 519
Nickname: charles
Registered: Feb, 2002
|
|
Re: compiling error
|
Posted: Mar 14, 2005 11:06 AM
|
|
On the surface, nothing looks wrong with the java statement:
for(int i=0;i<10;i++) gr.add(new Gerbil(i));
but from the error message, its saying that the object named gr is a List type of object, which has a method called add, which adds objects.
Your statment is saying that you are adding an anonymous Gerbil object which you create inside parnetheses, new Gerbil(i)
This is invoking a constructor of the class Gerbil which is supposed to take an int type of input argument.
I can't tell much without seeing more code. I would check the code to make sure you are using the correct Object or primitive argument types in this statement.
It may be that you have to do some kind of type case on the new gerbil object.
|
|