Collections public static Enumeration emptyEnumeration() Method Example Program


Returns an enumeration that has no elements.

Program

package com.candidjava;

/**
 * 
 * @author karthikeyan.T
 * @description Returns an enumeration that has no elements.
 */

public class CollectionsEmptyEnumeration {
	public static CollectionsEmptyEnumeration getInstance() {
		return enumeration;
	}

	public boolean hasMoreElements() {
		return false;
	}

	public Object nextElement() {
		return null;
	}

	protected static CollectionsEmptyEnumeration enumeration = new CollectionsEmptyEnumeration();
}

Output




Explanation

public static <T> Enumeration<T> emptyEnumeration()
Returns an enumeration that has no elements. More precisely,
hasMoreElements always returns false.
nextElement always throws NoSuchElementException.
Implementations of this method are permitted, but not required, to return the same object from multiple invocations.

Returns:
an empty enumeration
Since:
1.7


Related Post

Comments


©candidjava.com