Enumeration Interface in Java


Prev Tutorial Next Tutorial

Enumeration Interface in Java

It is one of the predefined interface and whose object is always used for retrieving the data from any legacy collection framework variable (like vector, stack, HasTable etc.) only in forward direction but not in backward direction. Like Iterator interface object, Enumeration Interface object is pointing just before the first element of any legacy collection framework variable.

The functionality of Enumeration is more or less similar to Iterator Interface but Enumeration Interface object belongs to synchronized and Iterator Interface object belong to non-synchronized.

Points to Remember

  • Enumeration does not support addition, removing and replacing og elements.
  • Enumeration is Synchronized.
  • Using Enumeration elements of legacy collection can be access only in forward direction.
  • Every legacy class contains following methods to work with enumeration and it returns enumeration object.

Methods of Enumeration Interface

  • public boolean hasMoreElements(): Return true if Enumeration contains more elements otherwise returns false.
  • public object nextElement(): Returns the next elements of Enumeration.

Create an object of Enumeration


Vector v=new Vector();
Enumeration e=v.elements();

Example of Enumeration

import java.util.Arraylist;

class EnumerationDemo
public static void main(String args[])

Vector<Integer> al=new vector<Integer>();  // creating Vector

Enumeration e=v.elements();
System.out.println("Forword Direction");  



Forword Direction

Prev Tutorial Next Tutorial


Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements

Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs