This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
Okay, now I have yet another question. I am trying to solve a simple problem. I have pairs of values in my TreeMap right now. I'm not sure I'm using the right data structure at all. I put them in a TreeMap because it allows you to maintain the mapping between two values and also to sort on the keys. What I have done so far is to sort the TreeMap and print it all out. I did this with code that uses and iterator that I found online. I don't totally understand it. I read the javadocs on iterators, though, but there doesn't seem to be an answer there. What I want to do is assign the values in the last five elements of the TreeMap to individual variables so that I can use them elsewhere. But how do you get at "last five" in a TreeMap? I see there's a method for getting the last element and one for removing an element. So I could theoretically get the last one and remove it five times. But that seems a little tacky. Is there a better way using the iterator? Am I even using the appropriate data structure? This is a really simple problem that seems to have an elusive answer. Thanks for any ideas, Rebecca