enumerate through a vector using java enumeration example _ java examples - java program sample...
DESCRIPTION
javaTRANSCRIPT
9/18/2015 Enumerate through a Vector using Java Enumeration Example | Java Examples Java Program Sample Source Code
http://www.javaexamples.com/enumeratethroughvectorusingjavaenumerationexample 1/3
Enumerate through a Vector using Java Enumeration Example
1. /*2. Enumerate through a Vector using Java Enumeration Example3. This Java Example shows how to enumerate through elements of a Vector4. using Java Enumeration.5. */6. 7. import java.util.Vector;8. import java.util.Enumeration;9. 10. public class EnumerateThroughVectorExample 11. 12. public static void main(String[] args) 13. //create a Vector object14. Vector v = new Vector();15. 16. //populate the Vector17. v.add("One");18. v.add("Two");19. v.add("Three");20. v.add("Four");21. 22. //Get Enumeration of Vector's elements using elements() method23. Enumeration e = v.elements();24. 25. /*26. Enumeration provides two methods to enumerate through the elements.27. It's hasMoreElements method returns true if there are more elements to28. enumerate through otherwise it returns false. Its nextElement method returns29. the next element in enumeration.30. */31. 32. System.out.println("Elements of the Vector are : ");33. 34. while(e.hasMoreElements())35. System.out.println(e.nextElement());36. 37. 38. /*39. Output would be40. Elements of the Vector are :41. One42. Two43. Three44. Four45. */
9/18/2015 Enumerate through a Vector using Java Enumeration Example | Java Examples Java Program Sample Source Code
http://www.javaexamples.com/enumeratethroughvectorusingjavaenumerationexample 2/3
Tweet 0 1
Advertisement:
Receive Latest Java examples in your email: Subscribe
Related Java Examples
Get Enumeration over Java Vector Example
Create Java ArrayList From Enumeration Example
Get Enumeration over Java ArrayList Example
Get Enumeration over Java HashSet Example
Add an element at specified index of Java Vector Example
Simple Java Vector Example
9/18/2015 Enumerate through a Vector using Java Enumeration Example | Java Examples Java Program Sample Source Code
http://www.javaexamples.com/enumeratethroughvectorusingjavaenumerationexample 3/3
Copy Elements of One Java Vector to Another Java Vector Example
Get Size of Java Vector and loop through the elements Example
0 Comments javaex Login1
Share⤤ Sort by Best
Start the discussion…
Be the first to comment.
Subscribe Add Disqus to your sited Privacyὑ
Recommend