Path: csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Jim Janney Newsgroups: comp.lang.java.programmer Subject: Re: How convert Iterator into Enumeration Date: Wed, 28 Nov 2012 14:01:21 -0700 Organization: squidly charisma Lines: 32 Message-ID: References: <74tcb8dm7vrkptq3s5oa83a2ann907grn6@4ax.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx04.eternal-september.org; posting-host="75975abe3fe3503ca7350803ab98e478"; logging-data="30857"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18RfttDCWglvMC4NZHizV2p" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:gDkuWXUygfXvIukTCSiWx1Y35KQ= sha1:2Th1hlpRfAo9RyMsAxnsolgH3N4= Xref: csiph.com comp.lang.java.programmer:20012 Roedy Green writes: > On Wed, 28 Nov 2012 11:11:47 -0700, Jim Janney > wrote, quoted or indirectly quoted > someone who said : > >>enumeration method in java.util.Collections. > > Are you referring to? > static Enumeration enumeration(Collection c) > > I don't see one that takes an Iterator. Yes, and yes. Not as general as adapting an Iterator, but good enough for the problem as originally described, which was to produce an Enumeration from a HashMap. Assuming that parametermap is declared as Map parametermap; you can write /** *

Retrieve the parameter names.

* * @return The names. */ public Enumeration getParameterNames() { return java.util.Collections.enumeration(parametermap.keyset()); } -- Jim Janney