public class jihe {
public static void main(String[] args) { HashSet hs = new HashSet(); hs.add("1"); hs.add("2"); Iterator it = hs.iterator(); while(it.hasNext()) { System.out.println(it.next()); } Hashtable ht = new Hashtable<>(); ht.put(1, "1"); Iterator itt = ht.keySet().iterator(); while(itt.hasNext()) { System.out.println(ht.get(itt.next())); } Iterator ittt = ht.entrySet().iterator(); while(ittt.hasNext()) { Entry en = (Entry) ittt.next(); System.out.println(en.getKey()+","+en.getValue()); } }}