您的位置:首页 > 其它

Enumeration

2016-04-25 13:35 274 查看
//第一个
Vector v = new Vector();
v.addElement("Lisa");
v.addElement("Billy");
v.addElement("Mr Brown");
Enumeration e = v.elements();// 返回Enumeration对象
while (e.hasMoreElements()) {
String value = (String) e.nextElement();// 调用nextElement方法获得元素
System.out.print(value);
}

///////////////////////////////////
//LisaBillyMr Brown


//第二个
Hashtable ht = new Hashtable();
ht.put("1", "One");
ht.put("2", "Two");
ht.put("3", "Three");
Enumeration e = ht.elements();
while (e.hasMoreElements()) {
System.out.println(e.nextElement());
}
///////////////////////////////////
/*
Three
Two
One
*/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: