Map -- Min value
Write a method that can return the minimum value from ta map
(DO NOT use sort method)
Solution:
public static int minValue( Map<String,Integer> map ) {
SortedSet<Integer> sm = new TreeSet<>(map.values());
return sm.first( );
}
Map<String, Double> map = new HashMap<String, Double>();
map.put("1.1", 1.1);
map.put("0.1", 0.1);
map.put("2.1", 2.1);
Double min = Collections.min(map.values());
System.out.println(min); // 0.1