遍历Enumeration
版权声明:http://blog.csdn.net/qq924862077/
public interface Enumeration<E> {
/**
* Tests if this enumeration contains more elements.
*
* @return <code>true</code> if and only if this enumeration object
* contains at least one more element to provide;
* <code>false</code> otherwise.
*/
boolean hasMoreElements();//判断是否包含元素
/**
* Returns the next element of this enumeration if this enumeration
* object has at least one more element to provide.
*
* @return the next element of this enumeration.
* @exception NoSuchElementException if no more elements exist.
*/
E nextElement();//获得下一个元素
}
通过Enumeration的源码分析可得,Enumeration有两个方法:
public class TestEnumeration{
public static void main(String[] args){
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);
}
}
}
遍历Enumeration的更多相关文章
- java如何遍历Enumeration
public class TestEnumeration{public static void main(String[] args){ Vector v = new Vector(); v.addE ...
- Java Enumeration接口
Enumeration接口定义 Enumeration接口与Iterator接口用法比较 一. 1.Enumeration接口定义 public interface Enumeration<E& ...
- javaWeb遍历获取session中的值
//方法一:通过遍历的方法进行遍历 String FileName=""; HttpSession session=request.getSession();//获取session ...
- Java中的不同遍历方式
已知一个Person类: public class Person implements Comparable<Person>{ String name; String id; public ...
- java遍历当前会话所有Session
//方法一:通过遍历的方法进行遍历 String FileName=""; HttpSession session=request.getSession();//获取session ...
- IO流,Properties基本功能和遍历
import java.util.Enumeration; import java.util.Iterator; import java.util.Properties; import java.ut ...
- 复习java基础第四天(集合:List、Map、Collections、Enumeration)
一.List: List 代表一个元素有序.且可重复的集合,集合中的每个元素都有其对应的顺序索引 List 允许使用重复元素,可以通过索引来访问指定位置的集合元素. List 默认按元素的添加顺序设置 ...
- 遍历集合的常见方式,排序,用lambda表示是怎样的
Collection集合的功能: Object[] toArray() 将集合转成数组 Iterator iterator() 通过方法的调用 获取I ...
- 取出session中的所有属性与值的方法
如果你想取出session中所有的属性和值,可以通过getAttributeNames()方法来实现,具体代码如下 //获取session HttpSession session = request. ...
随机推荐
- [洛谷P4178]Tree
题目大意:给一棵树,问有多少条路径长度小于等于$k$ 题解:点分治 卡点:无 C++ Code: #include <cstdio> #include <algorithm> ...
- POJ2417 Discrete Logging | A,C互质的bsgs算法
题目: 给出A,B,C 求最小的x使得Ax=B (mod C) 题解: bsgs算法的模板题 bsgs 全称:Baby-step giant-step 把这种问题的规模降低到了sqrt(n)级别 首 ...
- python通过SSH登陆linux并操作
使用python通过SSH登陆linux并操作 用的昨天刚接触到的库,在windows下通过paramiko来登录linux系统并执行了几个命令,基本算是初试成功,后面会接着学习的. 代码: > ...
- jquery判断ie与使用ie来判断ie,推荐ie样式块
用jquery来判断浏览器类型,如果只是仅仅为了判断浏览器的类型而使用该方法,那么不建议使用,只是在你已经使用了jquery才建议使用,因为没必要因为这么小的一个功能就加载那么大的类库吧 Jquery ...
- Selenium2设置隐式等待和显示等待
1. 设置显示等待 Java代码: public static WebElement WaitForElement(WebDriver driver, String locator) { WebEle ...
- Linux Mint---安装docky
这个安装的时候没啥难度,直接在软件中心安装一下就可以了,效果很赞的,linux下最棒的dock, 简洁大方,效果好! 只不有过一点需要注意,这个东东直接很上拖是添加不上去的 需要从/usr/share ...
- 跳石头(NOIP2015) (二分查找)
原题传送门 好久没更了..昨天去学zkw线段树,被zxyer狠狠地D了一顿.. 来补坑.. 这是一道很奇特的题目. 根据题目可以看出这道题有二分题具有的性质.. 不懂二分性质的可以看我以前的博客 传送 ...
- (转)Python 操作 Windows 粘贴板
转自: http://outofmemory.cn/code-snippet/3939/Python-operation-Windows-niantie-board Python 操作 Windows ...
- V4L2驱动的移植与应用(二+三)【转】
转自:http://blog.chinaunix.net/uid-10747583-id-298489.html 原文地址:http://blog.csdn.net/wxzking/archive/2 ...
- (十一)Ubuntu下面怎么找到一个软件安装的目录,卸载软件
aptitude show packagename 实例: aptitude show sublime-text-installer 可以看到这个软件一系列信息 dpkg命令 dpkg -l //列车 ...