title: How to get the key of a TreeMap by it's index?
body: <p>So I'm trying to get the key of a TreeMap by an int index.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>TreeMap&lt;String, Integer&gt; map = new TreeMap&lt;String, Integer&gt;(Collections.reverseOrder());
  map.put("hi", 1);
  map.put("hi2", 5);
  
  System.out.println("Key: " + (String) map.keySet().toArray()[0] + "\nValue: " + map.get(0));
  </code></pre>
  
  <p>But when I execute this, I get the error:</p>
  
  <pre><code>java.lang.Integer cannot be cast to java.lang.String
  </code></pre>
  
  <p>So I'm trying to get the key: "hi2"</p>