-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathVector.java
More file actions
31 lines (30 loc) · 826 Bytes
/
Vector.java
File metadata and controls
31 lines (30 loc) · 826 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
import java.util.*;
public class Vector
{
Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
//creating vector object
Vector<Integer> vec =new Vector<Integer>();
for(int i=0;i<7;i++){
vec.add(i);
}
//print vec
System.out.println("vec:"+vec);
//vector size..
System.out.println("vec_size:"+vec.size());
//vector_capacity
System.out.println("vec_capacity:"+vec.capacity());
//add element vec
vec.add(25);
//add element at index i
vec.add(1,45);
//vector first element
System.out.println("first_element:"+vec.firstElement());
//vector last element
System.out.println("first_element:"+vec.lastElement());
//vector contains
System.out.println("Element:"+vec.contains(26));
//vector index of
System.out.println("Index:"+vec.indexOf(25));
}
}