Java Program to Iterate Vector using Enumeration Last Updated : 10 Feb, 2022 Comments Improve Suggest changes Like Article Like Report The Vector class implements a growable array of objects. It is available in java.util package. It implements the List interface. The Enumeration interface defines the methods by which you can traverse the elements in a collection of objects. Now in order to add elements Vector Syntax: public class Vector<E> extends AbstractList<E> implements List<E>, RandomAccess, Cloneable, Serializable java.util.Enumeration interface is one of the predefined interfaces, whose object is used for retrieving the data from collections framework variable( like Stack, Vector, HashTable, etc.) in a forward direction only and not in the backward direction. You can use the Java.util.Vector.addElement() method to append a specified element to the end of this vector by increasing the size of the vector by 1. The functionality of this method is similar to that of the add() method of the Vector class. Syntax: boolean addElement(Object element) Parameters: This function accepts a single parameter element of object type and refers to the element specified by this parameter is appended to the end of the vector. Return Value: This is a void type method and does not return any value. Example 1: Java // Java Program to Iterate Vector using Enumeration // Importing Enumeration class import java.util.Enumeration; // Importing vector class import java.util.Vector; public class GFG { // Main driver method public static void main(String a[]) { // Creating a new vector Vector<String> v = new Vector<String>(); // Adding elements to the end v.add("Welcome"); v.add("To"); v.add("Geeks for"); v.add("Geeks"); // Creating an object of enum Enumeration<String> en = v.elements(); while (en.hasMoreElements()) { // Print the elements using enum object // of the elements added in the vector System.out.println(en.nextElement()); } } } OutputWelcome To Geeks for Geeks Example 2: Java // Java Program to Iterate Vector using Enumeration // Importing Enumeration class import java.util.Enumeration; // Importing Vector class import java.util.Vector; public class GFG { // Main driver method public static void main(String a[]) { // Creating a vector object Vector<Integer> v = new Vector<Integer>(); // Adding elements to the end v.add(1); v.add(2); v.add(3); v.add(4); // Creating an enum object Enumeration<Integer> en = v.elements(); while (en.hasMoreElements()) { // Displaying elements of vector class // calling enum object System.out.println(en.nextElement()); } } } Output1 2 3 4 Comment More infoAdvertise with us Next Article Java Program to Iterate Vector using Enumeration sravankumar_171fa07058 Follow Improve Article Tags : Java Technical Scripter Java Programs Technical Scripter 2020 Java-Vector +1 More Practice Tags : Java Similar Reads Get Enumeration over Java Vector In java, the vector is a typical dynamic array whose size can increase or decrease. While in array the size cannot be changed after declaration. We have to include file import java.util.Vector to use Vector and store values in it. Also, import java.util.Enumeration to use enumeration. Approach 1: Co 3 min read Iterate Over Vector Elements in Java Vector is like the dynamic array which can grow or shrink its size. Unlike array, we can store n-number of elements in it as there is no size limit. We can iterate over vector by the following ways: Simple for-loopEnhanced for-loopIteratorsEnumeration interface Method 1: Simple for-loop The idea is 4 min read Java Program to Read Elements using Enumeration in Hashtable The enumeration in java is one of the predefined interfaces, whose object is used for retrieving the data from collections framework variable(like Stack, Vector, HashTable, etc.) in a forward direction only and not in the backward direction. HashTable is a class The hash table class implements a Map 3 min read Program to Convert a Vector to List in Java Given a Vector, the task is to Convert Vector to List in Java Examples: Input: Vector: [1, 2, 3, 4, 5] Output: List: [1, 2, 3, 4, 5] Input : Vector = [a, b, c, d, e, f] Output : List = [a, b, c, d, e, f] Using Collections.list() method Syntax: List list = Collections.list(vec.elements()); Approach: 3 min read Java Program to Search an Element in Vector A vector in Java is a dynamic array that can be resized as needed. It is synchronized, which means it is safe in multi-threaded programs. To find an element in a Vector we have to loop through its elements to find a match. In this article, we will learn how to search for a component in a Vector usin 3 min read Searching Elements in Vector Using Index in Java Vector implements a dynamic array that means it can grow or shrink as required. Like an array, it contains components that can be accessed using an integer index. An element of a Vector can be searched using an index with different methods. Suppose if the element is not present in the Vector then th 4 min read Java Program to Copy Elements of ArrayList to Vector Vector implements List Interface, like ArrayList it also maintains insertion order but it is rarely used in the non-thread environment as it is synchronized, and due to which it gives a poor performance in adding, searching, deleting, and updating of its elements. To copy elements from one collectio 4 min read Get Enumeration over Java HashSet The HashSet class implements the Set interface, backed by a hash table which is a HashMap instance. There is no assurance as to the iteration order of the set, which implies that over time, the class does not guarantee the constant order of elements. The null element is allowed by this class. The ja 2 min read Java Program to Iterate Over Arrays Using for and for-each Loop In Java, arrays are a collection of elements of the same type. To access and manipulate elements, we can use iteration techniques such as the for loop and for-each loop (also known as the enhanced for loop).Program to Iterate Over Arrays Using for and for-each Loop in JavaIn the below example, we wi 1 min read Java Program to Create ArrayList From Enumeration 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 2 min read Like