简体   繁体   English

Java中Enumerator和Enumeration的区别

[英]Difference between Enumerator and Enumeration in java

Can any one please give clarification about these? 有人可以澄清一下吗? I am really confused. 我真的很困惑。

Enumeration is process of loop through the collection ( Enumeration ) (Generally called as Enumerator). 枚举是整个集合的循环过程( Enumeration )(通常称为Enumerator)。

Enums are different. 枚举不同。

An enum type is a type whose fields consist of a fixed set of constants 枚举类型是其字段由一组固定的常数组成的类型

Enumeration is an interface : Enumeration是一个接口:

http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Enumeration.html http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Enumeration.html

An object that implements the Enumeration interface generates a series of elements, one at a time. 实现Enumeration接口的对象会生成一系列元素,一次生成一个。 Successive calls to the nextElement method return successive elements of the series. 连续调用nextElement方法将返回该系列的连续元素。

Enumerators are a generic term. 枚举器是一个通用术语。 More of on the lines of Iterator. 有关Iterator的更多信息。

Enum - Define a set of constants and use it where ever required. Enum -定义一组常量,并在需要时使用它。

java.util.Enumeration helps iterate through a set of objects using .nextElement() . java.util.Enumeration帮助使用.nextElement()遍历一组对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM