quarta-feira, 30 de janeiro de 2013

Java HashMap e Iterator

import java.util.*; public class TestaHasMap { /** * @param args the command line arguments */ public static void main(String[] args) { HashMap hm = new HashMap(); hm.put("Valor1", new Double(3333.333)); Set s = hm.entrySet(); Iterator i = s.iterator(); while(i.hasNext()){ Map.Entry me = (Map.Entry) i.next(); System.out.print(me.getKey()+" : "); System.out.println(me.getValue()); } } }