Reputation: 416
TreeMap treemap=new TreeMap<String,double>();
treemap.put("02.00", 7.5);
treemap.put("03.30", 7.9);
treemap.put("04.00", 8.0);
treemap.put("05.30", 6.8);
treemap.put("10.00", 9.01);
treemap.put("11.30", 8.9);
treemap.put("12.00", 9.30);
System.out.println(treemap);
double min=(double) Collections.min(treemap.values());
Treemap contains -- {02.00=7.5, 03.30=7.9, 04.00=8.0, 05.30=6.8, 10.00=9.01, 11.30=8.9, 12.00=9.30} min contains value : 6.8
Now i want to iterate key and value after
treemap.put("05.30", 6.8);
i.e.,
treemap.put("10.00", 9.01);
treemap.put("11.30", 8.9);
treemap.put("12.00", 9.30);
and store last three map key and value in another treemap..
Upvotes: 1
Views: 786
Reputation:
TreeMap
has a method tailMap(K fromKey)
which returns a SortedMap<K, V>
whose keys are greater than / equal to K.
Upvotes: 7