eunmeration in java enumeration in java example enumeration example in java eunmeration in java tutorial
eunmeration in java api difference between enumeration and iterator difference between enumeration and iterator in java eunmeration in java 5 eunmeration in java example with hashtable enumeration vs iterator enumeration vs iterator in java eunmeration in java example 1.5 enumeration in java 6 tutorial difference between enumeration and list difference between enumeration and iterator java enumeration and iterator in java enumeration and iterator difference in java
Enumeration is one for the predefined interface present in java.util.* package. An object of Enumeration is always used for extracting or retrieving the data from any legacy collection frame work variable only in forward direction but not in back ward direction.
Like Iterator interface object, an object of Enumeration is also by default pointing before the first element of Legacy Collection Frame work variable.
The functionality of Enumeration is more or less similar to Iterator interface. But iterator interface belongs to non-synchronized and Enumeration interface belongs to synchronized.
Difference Between Iterator and Enumeration ?
Both Iterator and Enumeration Interfaces are used for extracting the data from any object, only in forward direction. But their differ in such that Iterator belongs to Non-synchronized and Enumeration belongs to synchronized(legacy collection frame work).
Methods in Enumeration :
1) Public boolean hasMoreElements():
This method is used to returns true provided Enumeration interface object having
more number of elements. Otherwise it returns false.
2) Public boolean nextElement() :
This method is used for obtaining next element of any Legacy collection frame work
variable w.r.t enumeration interface object provided method1 hasMoreElements() returns
The Following Example Illustrate the Concept of Enumeration Interface and it’s Method’s :
Consider Enumeration reference en and this reference pointing before Any object like Vector, Stack etc…. v or s .
The basic use of Enumeration interface is used to retrieve the elements in synchronize manner such that following code will illustrate it.
Public static void main(String args)
Vector v=new Vector();
// v contains elements as10,20.3,40.53
// to retrieve these elements
Data Extraction Interfaces are as follows :