import java.util.Hashtable; import java.util.Enumeration; class HTDemo { public static void main(String args[]) { Hashtable balance = new Hashtable(); Enumeration names; Enumeration negbal; String str; double bal; balance.put("John Doe", new Double(3434.34)); balance.put("Tom Smith", new Double(123.22)); balance.put("Jane Baker", new Double(1378.00)); balance.put("Tod Hall", new Double(99.22)); balance.put("Ralph Smith", new Double(-19.08)); // Muestra todos los balances de la tabla hash names = balance.keys(); while(names.hasMoreElements()) { str = (String) names.nextElement(); System.out.println(str + ": " + balance.get(str)); } System.out.println(); // Deposita 1,000 en la cuenta de John Doe bal = ((Double)balance.get("John Doe")).doubleValue(); balance.put("John Doe", new Double(bal+1000)); System.out.println("El nuevo saldo de John Doe es: " + balance.get("John Doe")); } }