I need to iterate through a TreeMap.

I won't be able to use another collection instead of a TreeMap, I am merely changing some code in someone else's program. Is it at all possible to do this?

I'm thinking:

while (Treemap.hasNext())

or something similar. Is this possible in Java?

I don't know. Have you checked the API for Treemap?

I think I have a solution:

// tm is a TreeMap with values in it
		 Set set = tm.entrySet();
			// Get an iterator
			Iterator i = set.iterator();
			// Display elements
			while(i.hasNext()) {

Hey thanks! You've been really helpfull. Appreciate it.