Like Peter said, an obvious possibility is that the Comparator (or Comparable implementation) sorts the wrong way around
You haven't defined any comparator for the TreeMap. You don't any way to compare Employees. You could implement interface Comparable in Employee. First off, you have name and payRate as static. static means related to the class. You want instance variables, so remove static modifier (You knew that, right?) Ok. Now You need to make a comparator or implement comparable interface for Employee.
The Comparator interface will allow you to make different types of comparisons (pay, first name, last name). Implementing Comparable interface allows just one type of comparison.
As a final note, it would be wise to declare numberEmployees as volatile.
For more information on thread safety, see Josh Bloch's Effective Java chapter on Synchronization. [ March 26, 2003: Message edited by: Garrett Smith ]
Looks like there's no need for a Comparator here - the keys being used are Integers, which implement Complarator:
Based on this, yes it looks like Rose should be associated with the first key. I can't tell from your code where the problem actually is. I can't compile and run it myself since other classes are missing. I'd suggest inserting somethiing like this for debugging:
You can insert this several different places. Try it immediately after empObjects has been initialized, and then also after the code that attempts to display the results in a text field. This way you can see if the problem is really in the map, or in the code that attempts to take the map values and put them on screen. Good luck... [ March 27, 2003: Message edited by: Jim Yingst ]
man! there is a bug in Employee class... all class members are "static" so even if everytime u create a new object all the values are overwritten hence only the last value is retained.. make Employee fields and method non-static and then see...it should work.. regards maulin.