title: How to find highest key value from hashmap
body: <p>iterate with max key value so that it will replace max string value. first My code is</p>
  
  <pre><code>HashMap&lt;String, String&gt; mapp=new HashMap&lt;String, String&gt;();
  mapp.put("ab","blue");
  mapp.put("abc","black");
  mapp.put("abcd","pink");
  for (Iterator it = alltyp.iterator(); it.hasNext();) {
      String finalstring = (String) it.next();
  
      Iterator it1=mapp.entrySet().iterator();
      while(it1.hasNext())
      {
          Map.Entry pairs = (Map.Entry) it1.next();
          String key_ = (String) pairs.getKey();
          String value_ = (String) pairs.getValue();
          finalstring = finalstring.replaceAll(key_, value_);      
      }
  }
  </code></pre>
  
  <p>I want to iterate with max key value means key value "abcd" should iterate first then "abc" then "ab".</p>