LinkedHashMap<String, Double> testMap = (LinkedHashMap<String, Double>) sortByValue(commands.get(commandWithMaxNegativeOffset).getDataUsageCriteria());
From above, testMap will contains something like {New=30.0, Previous=70.0} 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 key as value if condition gets matched by using key/value pair from map
double percent = r.nextDouble()*100;
if(percent > 1.0 && percent < 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 > 71 && percent < 100){
commands.get(commandWithMaxNegativeOffset).setDataCriteria(Use the Key of 30.0 i.e New);
}
If I understand you correctly, the following may be what you’re looking for: