-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTut20.java
More file actions
33 lines (28 loc) · 755 Bytes
/
Tut20.java
File metadata and controls
33 lines (28 loc) · 755 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
package tutorial;
import java.util.Vector;
//Vector Class
public class Tut20 {
public static void main(String[] args) {
// creating instance of vector
Vector<Integer> vc = new Vector<>();
vc.add(1);
vc.add(2);
vc.add(0, 10);
System.out.println(vc);
vc.set(2, 34);
System.out.println(vc);
System.out.println(vc.capacity());
System.out.println(vc.elementAt(1));
System.out.println(vc.firstElement());
System.out.println(vc.lastElement());
System.out.println(vc.indexOf(2));
System.out.println(vc.contains(34));
vc.remove(2);
System.out.println(vc);
vc.ensureCapacity(3);
System.out.println(vc.capacity());
vc.forEach(System.out::println);
System.out.println(vc.size());
System.out.println(vc.isEmpty());
}
}