title: Iterate over a TreeMap of Objects (not Strings!!) in Java
body: <p>I've got a Treemap of Servers:</p>
  
  <pre><code>TreeMap server_map = new TreeMap&lt;String, Server&gt;() ;
  </code></pre>
  
  <p>I'd like to iterate over the whole map to print all the servers. Using this kind of loop:</p>
  
  <pre><code>for (Map.Entry&lt;String, Server&gt; entry : server_map.entrySet())
  {
      System.out.println(entry.getKey() + "/" + entry.getValue().foo);
  }
  </code></pre>
  
  <p>This won't work, because there is an <em>Unresolved compilation problem:</em> </p>
  
  <blockquote>
    <p>Type mismatch: cannot convert from element type Object to Map.Entry</p>
  </blockquote>
  
  <p>Isn't there a possibility to iterate over a Treemap of servers?</p>