Enumeration是遍历集合元素的一种方法。

Enumeration中只有两个方法:

1.hasMoreElements()  测试此枚举是否包含更多的元素。

2.nextElement()  如果此枚举对象至少还有一个可提供的元素,则返回此枚举的下一个元素。

使用举例:

Enumeration<String> paraNames = request.getHeaderNames();
for(Enumeration e=paraNames;e.hasMoreElements();){

  String thisName = e.nextElement().toString();
  String thisValue = request.getHeader(thisName);
  System.out.println(thisName+"--------------"+thisValue);

}

Enumeration 接口的更多相关文章

  1. Java Enumeration接口

    Enumeration接口定义 Enumeration接口与Iterator接口用法比较 一. 1.Enumeration接口定义 public interface Enumeration<E& ...

  2. Vector类与Enumeration接口

    Vector类用于保存一组对象,由于java不支持动态数组,Vector可以用于实现跟动态数组差不多的功能.如果要将一组对象存放在某种数据结构中,但是不能确定对象的个数时,Vector是一个不错的选择 ...

  3. 20180824-Java Enumeration 接口

    Java Enumeration接口 Enumeration接口中定义了一些方法,通过这些方法可以枚举(一次获得一个)对象集合中的元素. 这种传统接口已被迭代器取代,虽然Enumeration 还未被 ...

  4. Java中Enumeration接口的用法

    Enumeration是java.util中的一个接口类,在Enumeration中封装了有关枚举数据集合的方法,与Iterator差不多,用来遍历集合中的元素  但是枚举Enumeration只提供 ...

  5. 【Java基础】9、Enumeration接口和Iterator接口的区别

    package java.util; public interface Enumeration<E> {     boolean hasMoreElements();     E next ...

  6. Enumeration 接口的使用

          Enumeration是一个接口,定义了两个规则,可以获取连续的数据,对数据结构非常重要.       接口源码: publicinterfaceEnumeration<E>{ ...

  7. Enumeration接口和Iterator接口的区别有哪些?

    Enumeration速度是Iterator的2倍,同时占用更少的内存.但是,Iterator远远比Enumeration安全,因为其他线程不能够修改正在被iterator遍历的集合里面的对象.同时, ...

  8. 枚举 Java Enumeration接口

    Enumation 定义了一些方法,通过这些方法可以枚举对象集合中的元素 如: boolean hasMoreElements() 测试此枚举是否包含更多的元素 object nextElement( ...

  9. 吴裕雄--天生自然java开发常用类库学习笔记:foreach及Enumeration接口

    import java.util.Vector; import java.util.Enumeration; public class EnumerationDemo01{ public static ...

随机推荐

  1. ganymedssh2 java执行linux命令

    需要下载ganymed-ssh2-262.jar package ganymed; import java.io.BufferedReader; import java.io.IOException; ...

  2. date 笔记

    1 语法 # date --help 用法:date [选项]... [+格式] 或:date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]] 1.1   ...

  3. 每日一笔记之3:QTconnect()

    刚学习QT的时候,跟着教程做一些简答的实验,教程简单的界面使用UI文件,直接在界面上拖一个按键,在右键go to slot,在编写槽函数. 我以前没学过C++,一直以为这个自动跳转过去的slot函数是 ...

  4. 虚拟机装centos 桥接方式上网[转]

    http://blog.csdn.net/sunbiao0526/article/details/6804127   虚拟机选择bridge方式连接网络 首先 vi /etc/sysconfig/ne ...

  5. Element can be click when out of view

    WebDriver can't action the element when out of view Webdriver can't action the element when the elem ...

  6. Spring事务的传播特性和隔离级别

    事务的几种传播特性1. PROPAGATION_REQUIRED: 如果存在一个事务,则支持当前事务.如果没有事务则开启2. PROPAGATION_SUPPORTS: 如果存在一个事务,支持当前事务 ...

  7. Ubuntu下配置和编译cpp-ethereum客户端

    Ethereum,中文翻译是“以太坊”,是一个公有区块链的开源项目.因为以太坊是基于P2P网络所以没有中心节点,所以用户仅安装Ethereum客户端即可连入Ethereum公共网络或者在自己的test ...

  8. 为什么要使用SLF4J而不是Log4J

      每一个Java程序员都知道日志对于任何一个Java应用程序,尤其是服务端程序是至关重要的,而很多程序员也已经熟悉各种不同的日志库如java.util.logging.Apache log4j.lo ...

  9. Mybatis 学习-2

    创建基于session的util类,在线程中共享SqlSession package cn.smartapp.blogs.pojo; import java.io.Serializable; impo ...

  10. HDU----(4291)A Short problem(快速矩阵幂)

    A Short problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...