Como recorrer un HashTable:
Hashtable a = getHashTable();
Enumeration e = a.keys();
Object obj;
while (e.hasMoreElements()) {
obj = e.nextElement();
System.out.println("clave "+ obj +": " + a.get(obj));
}
------------------------------------------------------------------------------------------
Como recorrer un MAP:
Map
hm.put("1","Luis");
hm.put("2","Amaya");
hm.put("3","Julio");
Iterator it = hm.entrySet().iterator();
while (it.hasNext()) {
Map.Entry e = (Map.Entry)it.next();
System.out.println(e.getKey() + " " + e.getValue());
No hay comentarios:
Publicar un comentario