
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get Enumeration over ArrayList with Java Collections
In order to get enumeration over ArrayList with Java Collections, we use the java.util.Collections.enumeration() method.
Declaration βThe java.util.Collections.enumeration() method is declared is as follows β
public static <T> Enumeration<T> enumeration(Collection<T> c)
where c is the collection object for which an enumeration is returned
Let us see a program to get enumeration over ArrayList β
Example
import java.util.*; public class Example { public static void main (String[] args) { ArrayList<Integer> list = new ArrayList<Integer>(); list.add(14); list.add(2); list.add(73); Enumeration en = Collections.enumeration(list); // getting enumeration over ArrayList list while(en.hasMoreElements()) { System.out.println(en.nextElement()); } } }
Output
14 2 73
Advertisements