-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVectorExample.java
More file actions
28 lines (20 loc) · 621 Bytes
/
VectorExample.java
File metadata and controls
28 lines (20 loc) · 621 Bytes
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
package collection;
import java.util.Enumeration;
import java.util.Vector;
public class VectorExample {
public static void main(String[] args) {
Vector<String> vec = new Vector<String>();
/* Adding elements to a vector */
vec.addElement("Apple");
vec.addElement("Orange");
vec.addElement("Mango");
vec.addElement("Fig");
System.out.println("Size is: " + vec.size());
/* Display Vector elements */
Enumeration<String> en = vec.elements();
System.out.println("\nElements are:");
while (en.hasMoreElements()) {
System.out.print(en.nextElement() + " ");
}
}
}