1:01 pm - Wednesday February 22, 2017

This Program is used to get an enumeration over the specified collection using enumeration(Collection) method

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

BACK

This Program is used to get an enumeration over the specified collection using enumeration(Collection<T>) method

Example Program


import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;

public class Main {
	public static void main(String args[]) {
		ArrayList<String> a1 = new ArrayList<String>();

		a1.add("A");
		a1.add("B");
		a1.add("c");
		Enumeration<String> e = Collections.enumeration(a1);

		while (e.hasMoreElements()) {
			System.out.println("Value is: " + e.nextElement());
		}
	}
}


 

OUTPUT:


value is: A
Value is: B
Value is: C

 

Explanation:

The enumeration(Collection<T>) method is used to get an enumeration over the specified collection.

 

Parameter:

 

  • c–This is the collection for which an enumeration is to be returned.

 

Return Value:

The method call returns an enumeration over the specified collection.

 

Exception:NA

 

 

BACK

Filed in: Z-A All Java Codes

Comments are closed.