Results 1 to 5 of 5
Thread: help!, while loop wont stop!
- 03-24-2011, 02:01 AM #1
Member
- Join Date
- Mar 2011
- Posts
- 8
- Rep Power
- 0
help!, while loop wont stop!
hello, i'm trying to iterate hashmap with while loop, when i send the hashmap to system.out, it gives me the object, when i look at its size, it says 1013.
so the hashmap is fine i think.
here's the code
is the while loop right?, because in system out, the i++ never stops.Java Code:int i = 0; Iterator hashIterator = hMap.keySet().iterator(); while(hashIterator.hasNext()){ i++ }
and like i said before if i try system.out on the hMap.keySet, it gives me all my key set.
any idea??
- 03-24-2011, 02:15 AM #2
Your condition will either be false or it will always be true. You never actually iterate over anything.
- 03-24-2011, 02:20 AM #3
Member
- Join Date
- Mar 2011
- Posts
- 8
- Rep Power
- 0
thanks, i understand, so what do i have to add into the while to iterate?
is it remove item every loop?
- 03-24-2011, 02:22 AM #4
You have created an Iterator. Why not take a look at what methods it has.
- 03-24-2011, 02:27 AM #5
Member
- Join Date
- Mar 2011
- Posts
- 8
- Rep Power
- 0
Similar Threads
-
Why Wont This Work???
By Billywizz in forum New To JavaReplies: 11Last Post: 03-09-2011, 02:33 AM -
code wont enter into loop. thanks in advance for your help
By farahm in forum Advanced JavaReplies: 7Last Post: 11-22-2010, 02:38 PM -
The outer loop doesnt stop running
By Bulelakes in forum JDBCReplies: 16Last Post: 08-23-2010, 09:42 AM -
Use stop button to stop moving (stop timers) on JPanel
By mneskovic in forum New To JavaReplies: 3Last Post: 07-23-2010, 12:50 PM -
why wont it compile
By bje98f in forum Advanced JavaReplies: 1Last Post: 04-23-2009, 10:55 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks