On 10/25/05, Matt Williams <matthew.williams@...> wrote:
> Dear List,
> I've managed to get very stuck on trying to iterate over a Java HashMap.
> ja_map =3D <some java hash map>
> I'm trying to extract the values one-by-one.
> For i in ja_map:
> print i
> print ja_map[i]
> but my attempt to access the java iterator also fails:
> while ja_map.iterator().hasNext()
> print ja_map.next()
> As it always returns the same value.
> I know this must be possible - any ideas?
This works fine in the Jython 2.2a1 release, which does have support
for iterators. The main reason you're having trouble, though, is that
there's a bug in your program. Call .next() on the iterator, not on
the Map, and I expect it to work.
Bill Woodward wpwood@... http://www.saifa.net
"I have more trouble with D. L. Moody than with any other man I ever
met." -- D. L. Moody
s/D. L. Moody/Bill Woodward/g