for语句一般是for(初值表达式;条件表达式;迭代因子){}
这个for语句怎么理解:
for(Enumeration e=ht.elements();e.hasMoreElements();)
System...........
完整如下:import java.util.*;
public class Hashtable{
public static void main(String[] args){
Hahstable ht=new Hashtable();
ht.put("0011-123","江泽民");
ht.put("0012-456","李鹏");
ht.put("0013-789","李瑞环");
System.out.println("<目录>");
for(Enumeration e=ht.element();e.hasMoreElement();)
System.out.println(e.nextElement());
}
}
这个for语句怎么理解:
for(Enumeration e=ht.elements();e.hasMoreElements();)
System...........
完整如下:import java.util.*;
public class Hashtable{
public static void main(String[] args){
Hahstable ht=new Hashtable();
ht.put("0011-123","江泽民");
ht.put("0012-456","李鹏");
ht.put("0013-789","李瑞环");
System.out.println("<目录>");
for(Enumeration e=ht.element();e.hasMoreElement();)
System.out.println(e.nextElement());
}
}
这里加了
结构类似于for(i=0;i<10){
i++;
}
循环条件:e.hasMoreElement()
循环体:System.out.println(e.nextElement());
你把它带进去就行了
这个for换了身马甲,我还真认不出他了,不过由于是初学,各位的指点还待下来慢慢琢磨.真的感谢各位老大!