TreeMap
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
class TreeMapDemo {
public static void main(String args[]) {
TreeMap<String, Double> tm = new TreeMap<String, Double>();
tm.put("A", new Double(3.34));
tm.put("B", new Double(1.22));
tm.put("C", new Double(1.00));
tm.put("D", new Double(9.22));
tm.put("E", new Double(-1.08));
Set<Map.Entry<String, Double>> set = tm.entrySet();
for (Map.Entry<String, Double> me : set) {
System.out.print(me.getKey() + ": ");
System.out.println(me.getValue());
}
double balance = tm.get("A");
tm.put("B", balance + 1000);
System.out.println(tm.get("A"));
}
}
Related examples in the same category