Hello, welcome to practice house.
In this post, we will learn about how to Read All Elements in Vector Using Enumeration. we will use elements() method to convert our vector to an Enum.
Then we will use hasMoreElements() to retrieve our data.
Enumeration elements()
Returns an enumeration of the components of this vector.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
package com.practice.house; import java.util.Enumeration; import java.util.Vector; /** * * @author marifurr */ public class JavaVector { public static void main(String[] args) { Vector<String> vct = new Vector<String>(); //Adding Elements vct.add("First"); vct.add("Second"); vct.add("Third"); vct.add("Random"); //Enumeration elements() //Returns an enumeration of the components of this vector. Enumeration<String> enm = vct.elements(); while (enm.hasMoreElements()) { System.out.println(enm.nextElement()); } } } |
Sample Output :
Thanks For Reading this post. if you reading this it means you liked it. If you have any comments, questions or any suggestion about this post please post in below.
Happy Coding, Happy Living

Java – PHP – Python – Dart – Flutter – MySql – Spring – Hibernate – JavaScript – jQuery – BootStrap 4 – CSS – HTML
I love to explore new technologies. If you like my tutorials please share your thoughts about my work.
Check out my YouTube Channel For Video Tutorials.
To Hire Me Please Contact Me Through Social Media or https:www.amialif.com
If you want to help others by doing donation please Help Them.
You also can connect with me via social media. Thanks
Leave a Reply