VOOZH about

URL: https://www.geeksforgeeks.org/java/java-collections-emptyenumeration%e2%80%8b-method-with-examples/

⇱ Java Collections emptyEnumeration()​ Method with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Java Collections emptyEnumeration()​ Method with Examples

Last Updated : 27 Apr, 2023

The emptyEnumeration() method of Java Collections is used to get the empty enumeration that contains no elements in Java.

Syntax:

public static <T> Enumeration<T> emptyEnumeration() 

Parameters: This method has no parameters.

Return Type: This method will return an empty enumeration.

Exceptions: This method will not arise any exceptions.

Example 1: Java program to check whether the enumeration has more elements or not. So we are using the hasMoreElements() method. This will return a boolean value. If the enumeration contains elements, it will return true, otherwise false.

Syntax:

object.hasMoreElements()

where object is an enumeration object


Output
false

Example 2: In this example, we are going to get the next element of the empty enumeration using nextElement().

Syntax:

object.nextElement()

where object is an enumeration object


Output
Empty
Comment