VOOZH about

URL: https://www.geeksforgeeks.org/java/collections-enumeration-method-in-java-with-examples/

⇱ Collections enumeration() method in Java with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Collections enumeration() method in Java with Examples

Last Updated : 8 Jun, 2021

The enumeration() method of java.util.Collections class is used to return an enumeration over the specified collection. This provides interoperability with legacy APIs that require an enumeration as input.
Syntax: 
 

public static Enumeration enumeration(Collection c)


Parameters: This method takes the collection c as a parameter for which an enumeration is to be returned.
Return Value: This method returns an enumeration over the specified collection.
Below are the examples to illustrate the enumeration() method
Example 1: 
 


Output: 
List: [Ram, Gopal, Verma]

Enumeration over list: 
Value is: Ram
Value is: Gopal
Value is: Verma

 

Example 2: 
 


Output: 
List: [20, 30, 40]

Enumeration over list: 
Value is: 20
Value is: 30
Value is: 40

 
Comment