Infinite for loop
hi
I have the following for loop:
for (TreeMap <String, Integer> i = result; i.size()!=0; i.headMap (i.lastKey()))
{out.println("keyword = " + i.lastKey() + " ; page no. = " + i.get(i.lastKey()));
result is a tree map that contains several strings (the keys) and integers (values).
I need to note that in the process of creating result some values (i.e. strings) were repeated and therefore their values were replaced (run over).
When I run the program it just perform the loop again and again without getting rid of the last value / key pair in i in every iteration.
Can anyone explain why this is?
thanks in advance.
[682 byte] By [
razleva] at [2007-10-3 2:19:12]

hi
I have the following for loop:
for (TreeMap <String, Integer> i = result; i.size()!=0; i.headMap (i.lastKey()))
{out.println("keyword = " + i.lastKey() + " ; page no. = " + i.get(i.lastKey()));
result is a tree map that contains several strings (the keys) and integers (values).
I need to note that in the process of creating result some values (i.e. strings) were repeated and therefore their values were replaced (run over).
When I run the program it just perform the loop again and again without getting rid of the last value / key pair in i in every iteration.
Can anyone explain why this is?
thanks in advance.