• Enumeration接口源码阅读


    Enumeration接口源码阅读


    package java.util;
    

    An object that implements the Enumeration interface generates a series of elements, one at a time. Successive calls to the nextElement method return successive elements of the series. For example, to print all emelemts of a Vactor V:

    for(Enumetation<E> e = v.emelemts(); e.hasMoreElements();){
     System.sout.println(e.nextElement());
    }
    

    generates:生成 a series of:一系列 successive:连续 specify ... to ...:指定给

    Methods are provided to enumerate through the elements of a vector, the keys of a hashtable, and the values in a hashtable. Enumerations are alse used to specify the input streams to a SequenceInputStream.

    functionality:功能性 is duplicated by:被复制 in addition:此外 consider:考虑

    in preference to:优先于

    NOTE: The functionality of this interface is duplicated by the Iterator interface. In addition, Iterator adds an optional remove operation, and has shorter method names. New implementations should consider using Iterator in preference to Enumeratoin.

    Since: JDK1.0

    Author: Lee Boynton

    public interface Enumeration<E> {
    

    Tests if this enumeration contains more elements.

    Returns: true if and only if this enumeration object contains at least one more element to privide; false otherwise.

    boolean hasMoreElements();
    

    Returns the next element of this enumeration if this enumeration object has at least one more element to provide.

    Returns: the next element of this enumeration.

    Throws: NoSuchElementException - if no more elements exist.

    E nextElement();
    
    }
    

    总结

    1. Iterator接口包含Enumeration接口的所有方法(并且具有更简洁的名字),同时Iterator具有能够修改底层集合的方法,所以应该优先使用Iterator接口。
  • 相关阅读:
    基于jQuery弹性展开收缩菜单插件gooey.js
    动态插入和移除
    匹配0-59 0-23 的正则表达式
    换行问题
    iOSBug -- The file “Info.plist” couldn’t be opened
    MarkDown语法
    Mac -- 右键添加pages文件
    iOS -- 使用蒲公英进行内测
    Mac使用技巧--如何给safari安装翻译插件
    iOS--优化
  • 原文地址:https://www.cnblogs.com/XiaoZhengYu/p/12871568.html
Copyright © 2020-2023  润新知