-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVectorExample.java
More file actions
35 lines (25 loc) · 851 Bytes
/
Copy pathVectorExample.java
File metadata and controls
35 lines (25 loc) · 851 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
29
30
31
32
33
34
35
package collectionExampleList;
import java.util.*;
public class VectorExample {
public static void main(String[] args) {
// TODO Auto-generated method stub
Vector<String> vr = new Vector<String>();
vr.add("RED");
vr.add("YELLO");
vr.add("GREEN");
vr.add("BLUE");
vr.add("BLACK");
vr.add("WHILTE");
System.out.println("vactor Ex : "+vr);
/* Iterator ir =vr.iterator();
while(ir.hasNext()) {
System.out.println(ir.next());
}*/
System.out.println("\nUsing Lambda Expression : \n");
vr.forEach(i -> System.out.println(i)); //Lambda expression
//ele read every ele of vr & sysout we need to write what we need to print.
vr.remove(1);
System.out.println("\n After removing color on first index : \n");
vr.forEach(element -> System.out.println(element));
}
}