import java.util.Hashtable;
import java.util.Iterator;
import java.util.Set;
class HTDemo2 {
public static void main(String args[]) {
Hashtable<String, Double> balance = new Hashtable<String, Double>();
String str;
double bal;
balance.put("A", 3434.34);
balance.put("B", 123.22);
balance.put("C", 1378.00);
balance.put("D", 99.22);
balance.put("E", -19.08);
Set<String> set = balance.keySet();
Iterator<String> itr = set.iterator();
while (itr.hasNext()) {
str = itr.next();
System.out.println(str + ": " + balance.get(str));
}
System.out.println();
bal = balance.get("A");
balance.put("A", bal + 1000);
System.out.println("A's new balance: " + balance.get("A"));
}
}
|