Set the Key of HashMap to setter
<pre><code>LinkedHashMap&lt;String, Double&gt; testMap = (LinkedHashMap&lt;String, Double&gt;) sortByValue(commands.get(commandWithMaxNegativeOffset).getDataUsageCriteria());
</code></pre>

<p>From above, <code>testMap</code> will contains something like <code>{New=30.0, Previous=70.0}</code> in ascending order of value so what I want to do is something like below in the if/else loop, as currently I have hardcoded now just to make more sense but I want to use the testMap instead of hardcoding. I want to set <code>key</code> as value if condition gets matched <code>by using key/value pair from map</code></p>

<pre><code>double percent = r.nextDouble()*100;

if(percent &gt; 1.0 &amp;&amp; percent &lt; 70.0(how can I use 70 from testMap instead of hardcoding)) {
//what to put below in place of Previous
    commands.get(commandWithMaxNegativeOffset).setDataCriteria(Use the Key of 70.0 i.e Previous);
} else if(percent &gt; 71 &amp;&amp; percent &lt; 100){
    commands.get(commandWithMaxNegativeOffset).setDataCriteria(Use the Key of 30.0 i.e New);
}
</code></pre>
