Re: iterator.



On Thu, 29 Dec 2005 13:55:50 -0500, "ste1986" <steiddon_1@xxxxxxxxxxx>
wrote, quoted or indirectly quoted someone who said :

>public volunteer.add(new Volunteer(String name, int telephone))
> {
> Iterator it = volunteers.iterator();
> while (it.hasNext())
> {
> Volunteers volunteers = (Volunteers) it.next();
> if (volunteers.getName().equals(name))
> return true;
> }
> return false;
> }
>}

What is this supposed to be?
If a method declaration, you can't have a dot in a method name.
If this is supposed to be an anonymous class, then you don't want the
word public there.

Iterators are more neatly handled with for:each.

The contains method might do what you want if your volunteers supports
it.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
.