title: Java TreeMap return key position
body: <p>i Have this tree map:</p>
  
  <pre><code>Map teamNameAndLeague = new TreeMap();
  
  teamNameAndLeague.put("team1", "name1");
  teamNameAndLeague.put("team2", "name2");
  teamNameAndLeague.put("team3", "name3");
  </code></pre>
  
  <p>How can i search for a key and return index of that key Example:</p>
  
  <pre><code>search for key: "team1" in teamNameAndLeague, Returns index: 1
  </code></pre>
  
  <p>i have this:</p>
  
  <pre><code>int indexWin = new ArrayList&lt;String&gt;(teamNameAndLeague.values()).indexOf("name2") + 1;
  
  That returns: 2
  </code></pre>
  
  <p>it returns the index for this key but for search on key value. How can i make something similar but instead search for key</p>