[H-GEN] Which is better?

Paul Gearon pag at tucanatech.com
Mon Apr 26 23:34:49 EDT 2004


David Seikel wrote:

> Java has it's collections framework, which allows something like that.
> 
> for (Enumeration commands = servletToDo.elements(); commands.hasMoreElements();)
> {
>     String command = (String) commands.nextElement();
>     ...
> }
> 
> An example from my own code (but word wrapped by my email client).

Ooooooh, I haven't seen Enumerations in a while!

You should note that the collections framework now supports "iterators" rather 
than enumerators.  Some collection classes do support enumerators (namely, 
StringTokenizer and Vector... maybe others) but most don't.

The documentation on Enumeration says:

NOTE: The functionality of this interface is duplicated by the Iterator 
interface. In addition, Iterator adds an optional remove operation, and has 
shorter method names. New implementations should consider using Iterator in 
preference to Enumeration.

-- 
Regards,
Paul Gearon

Software Engineer                Telephone:   +61 7 3876 2188
Tucana Technologies              Fax:         +61 7 3876 4899
                                  http://www.tucanatech.com

Catapultam habeo. Nisi pecuniam omnem mihi dabis, ad caput tuum saxum
immane mittam.
(Translation from latin: "I have a catapult. Give me all the money,
or I will fling an enormous rock at your head.")





More information about the General mailing list