-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVectorExample.java
More file actions
45 lines (45 loc) · 1.9 KB
/
Copy pathVectorExample.java
File metadata and controls
45 lines (45 loc) · 1.9 KB
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
36
37
38
39
40
41
42
43
44
45
import java.sql.SQLOutput;
import java.util.*;
public class VectorExample {
public static void main(String[] args) {
// ---------------------------- 1st Constructor --------------------------------------
// Vector<String> vc = new Vector<>(5);
// System.out.println(vc.size() + " " + vc.capacity());
// vc.add("1");
// vc.add("2");
// vc.add("3");
// vc.add("4");
// System.out.println(vc.size() + " " + vc.capacity());
// --------------------------- 2nd Constructor --------------------------------------
// Vector<String> vc2 = new Vector<>(5);
// System.out.println(vc2.size() + " " + vc.capacity());
// for (int i = 1; i <= 5; i++) {
// vc2.add(Integer.toString(i));
// }
// System.out.println(vc2);
// System.out.println(vc2.size() + " " + vc2.capacity());
// vc2.add("6");
// System.out.println(vc2.capacity());
// ------------------------------- 3rd Constructor -------------------------------------
// Vector<String> vc3 = new Vector<>(5, 2);
// --------------------------Add all method -----------------------------------------
// Vector<String> vc1 = new Vector<>();
// vc1.add("1");
// vc1.add("2");
// vc1.add("3");
// vc1.add("4");
// Vector<String> vc2 = new Vector<>();
// vc2.addAll(vc1);
// System.out.println("Vc1 = " + vc1);
// System.out.println("Vc2 = " + vc2);
// ------------------------Clear Method-----------------------------------------------
// Vector<String> vc1 = new Vector<>();
// vc1.add("1");
// vc1.add("2");
// vc1.add("3");
// vc1.add("4");
// System.out.println("Before Clear Vc : " + vc1);
// vc1.clear();
// System.out.println("After Clearing Vc : " + vc1);
}
}