> Why am I getting an error that says:
> C:\Program Files\Xinox Software\JCreator
> LE\MyProjects\Assignment#1cs260\Bag.java:65: cannot
> resolve symbol
> symbol : method next ()
> location: interface Iterator
> add( iterator.next());
>
I didn't get that error but I got plenty of others. To start it is not necessary to close methods with a semi-colon. For example, this is not necessary
public void myMethod()
{
// do something here
}; // <-- see semi-colon
Try this
public void myMethod()
{
// do something here
} // note no semi-colon
Secondly, a lot of the Collection methods had not been implemented, for example,
public int size()
public boolean isEmpty()
public boolean contains( Object o )
public Object[] toArray()
public Object[] toArray( Object o[] )
public boolean remove( Object o )
public boolean containsAll( Collection c )
public boolean removeAll( Collection c )
public boolean retainAll( Collection c )
Finally, your hasNext() method in class Iterd should return a value in the event of not finding another element.
public boolean hasNext()
{
index=0;//resets the index so it starts at the beginning.
if(wallet[++index]!=null)
return true;
else
return false;
}
I suspect the error you got is misleading. Make the changes I suggested and let us know if you're still having problems.
Adam