Enumeration类不是一种数据结构,但是它对其他数据结构十分重要
它可以从别的数据结构获得连续的数据元素,比如遍历栈
这个类有两个方法
- hasMoreElements()
这是检测Enumeration 对象是否还有元素,有则返回true,否则faluse
- nextElement()
如果Enumeration对象还有元素,该方法得到下一个元素
Enumeration<?> pNames = request.getParameterNames();
Map<String, Object> params = new HashMap<String, Object>();
while (pNames.hasMoreElements()) {
String pName = (String) pNames.nextElement();
if (SIGN_KEY.equals(pName))
continue;
Object pValue = request.getParameter(pName);
params.put(pName, pValue);
}
博客介绍了Enumeration类,它虽不是数据结构,但对其他数据结构很重要,可从别的数据结构获取连续数据元素,如遍历栈。还介绍了该类的两个方法,hasMoreElements()用于检测是否还有元素,nextElement()用于获取下一个元素。
3100

被折叠的 条评论
为什么被折叠?



