 
View Full Version : [Java]Iteratori
Kleidemos
17-06-2003, 11:02
Esistono in java il corrispondente degli iteratori della lib STL del C++?
Tnk
tutte le classi "container" (ArrayList, HashMap, ecc.ecc ) ritornano un java.util.Iterator che puoi usare per "scorrere" all'interno dell'oggetto
Kleidemos
17-06-2003, 11:47
ma fai un esempio?
Originally posted by "Kleidemos"
ma fai un esempio?
import ecc.ecc.
HashMap hm = new HasMap();
hm.put("1", "uno");
hm.put("2", "due");
Iterator i = hm.keySet().iterator();
while(i.hasNext())
{
    Object s = i.next();
   System.out.println("Chiave: " + (String)s + "  Valore: " + (String)hm.get(s));
}
Kleidemos
17-06-2003, 12:11
tnk 1000000000000000000
vBulletin® v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.