Java Program to Create ArrayList From Enumeration Last Updated : 03 Mar, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report Enumerations serve the purpose of representing a group of named constants in a programming language. Enums are used when we know all possible values at compile-time, such as choices on a menu, rounding modes, command-line flags, etc. It is not necessary that the set of constants in an enum type stay fixed for all time. Steps To create an ArrayList from an Enumeration: Create a vector and add elements to it.Use the elements() method of vector to get the enumeration of the vector element.Using the list(Enumeration e) method of the Collections to get the ArrayList. Java // Java program to Create Java ArrayList From Enumeration import java.util.ArrayList; import java.util.Collections; import java.util.Enumeration; import java.util.Vector; class GFG { public static void main(String[] arg) { // creating and adding elements to Vector Vector<String> v = new Vector<String>(); v.add("Geeks"); v.add("For"); v.add("Geeks"); v.add("2020"); v.add("2021"); // Displaying vector elements System.out.println("Elements in vector : " + v); // getting enumeration of the vector element Enumeration<String> elementsEnumeration = v.elements(); // list(Enumeration e) method returns an ArrayList // containing the elements returned by the // specified Enumeration ArrayList<String> arrayList = Collections.list(elementsEnumeration); // Displaying arraylist element System.out.println("Elements in arraylist : " + arrayList); } } Output: Elements in vector : [Geeks, For, Geeks, 2020, 2021]Elements in arraylist : [Geeks, For, Geeks, 2020, 2021] Comment More infoAdvertise with us Next Article Program to convert Array to Set in Java L le0 Follow Improve Article Tags : Java Technical Scripter Java Programs Technical Scripter 2020 Java-Collections Java-ArrayList Java-Enumeration +3 More Practice Tags : JavaJava-Collections Similar Reads Get Enumeration Over Java ArrayList ArrayList class is a re-sizeable array that is present in java.util package. Unlike the built-in arrays, ArrayList can change their size dynamically where elements can be added and removed from an ArrayList. In java version 1, enum was not present. With advancement to version, 1.5 enum was introduce 3 min read Program to convert Array to Set in Java Array is a group of like-typed variables that are referred to by a common name. An array can contain primitives data types as well as objects of a class depending on the definition of the array. In the case of primitives data types, the actual values are stored in contiguous memory locations. In cas 7 min read Java Program to Convert an Array into a List In Java, arrays and lists are two commonly used data structures. While arrays have a fixed size and are simple to use, lists are dynamic and provide more flexibility. There are times when you may need to convert an array into a list, for instance, when you want to perform operations like adding or r 4 min read Java Program to Change a Collection to an Array An array is a data structure that can hold a fixed-size, homogeneous collection of elements of the same data type, which can be either primitive data types (e.g., int, float) or object references. However, the size of the array cannot be changed once it is created. On the other hand, a collection is 3 min read Convert ArrayList to Vector in Java There are several ways to convert ArrayList to Vector. We can use a vector constructor for converting ArrayList to vector. We can read ArrayList elements one by one and add them in vector. Approach 1: (Using Vector Constructor) Create an ArrayList.Add elements in ArrayList.Create a vector and pass t 3 min read Java Program to Convert Integer List to Integer Array There are many ways to convert integer List to ArrayList where in this article we will be discussing out 2 approaches as below: Using concept od streams in Java8Using Apache Commons LangUsing Guava Library Method 1: Using concept od streams in Java8 So, first, we will get to know about how to conver 3 min read Like