- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What does the method elements() do in java?
The elements() method is used to return an enumeration of the components of this vector. The returned Enumeration object will generate all items in this vector at the similar index location.
Example
import java.util.Vector; public class VectorDemo { public static void main(String[] args) { Vector<Integer> vec = new Vector<Integer>(4); vec.add(4); vec.add(3); vec.add(2); vec.add(1); Enumeration e=vec.elements(); System.out.println("Numbers in the enumeration are :- "); while (e.hasMoreElements()) { System.out.println("Number = " + e.nextElement()); } } }
Output
Numbers in the enumeration are :- Number = 4 Number = 3 Number = 2 Number = 1
- Related Articles
- What does the method clear() do in java?
- What does the method clone() do in java?
- What does the method firstElement() do in java?
- What does the method lastElement() do in java?
- What does the method removeAllElements() do in java?
- What does the method size() do in java?
- What does the method isEmpty() do in java?
- What does the method toArray() do in java?
- What does the method pop() do in java?
- What does the method peek() do in java?
- What does the method empty() do in java?
- What does the method trimToSize() do in java?
- What does the method getFirst() do in java?
- What does the method getLast() do in java?
- What does the method removeFirst() do in java?

Advertisements