

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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
- Related Questions & Answers
- Get Enumeration over HashSet in Java
- Shuffle elements of ArrayList with Java Collections
- Swap elements of ArrayList with Java collections
- Replace All Elements Of ArrayList with with Java Collections
- Find maximum element of ArrayList with Java Collections
- Find minimum element of ArrayList with Java Collections
- Perform Binary Search on ArrayList with Java Collections
- Copy Elements of One ArrayList to Another ArrayList with Java Collections Class
- Reverse order of all elements of ArrayList with Java Collections
- Sort ArrayList in Descending order using Comparator with Java Collections
- Replace all occurrences of specified element of ArrayList with Java Collections
- Java Program to Iterate over an ArrayList
- Enumeration in Java
- When to use LinkedList over ArrayList in Java
- Java Lambda Expression with Collections
Advertisements