This is my program , could anybody please tell me how do i get Map's key based on the value .
I have tried as
String vendor_name = map.get("value");
But its returing me null
import java.util.Collections;
import java.util.HashMap;
public class Test {
public static void main(String args[]) {
HashMap<String, String> for_highest_price_vendor = new HashMap<String, String>();
for_highest_price_vendor.put("vendor1", "20");
for_highest_price_vendor.put("vendor2", "25");
String maxValueInMap = (Collections.max(for_highest_price_vendor
.values())); // This will return max value in the Hashmap
String vendor_name = for_highest_price_vendor.get(maxValueInMap);
System.out.println(vendor_name);
}
}