Java Vector class method working of vector

 Java Vector class method implementation

Java Code for vector class methods maximum method implemented in this code!

package com.vector;


import java.util.*;


public class Vector2 {

public static void main(String[] args) {

//vector size

int m = 7;

//declaring vector of size m

Vector<Integer> v = new Vector<Integer>(m);

//adding element in vector

for(int i =1;i<=m;i++)

v.add(i);

//printing element

System.out.println(v);

//remove element of index 2

v.remove(2);

System.out.println(v);

//iterating vector

for(int i=0;i<v.size();i++)

//printing individual one by one element

System.out.print(v.get(i)+" ");

}

}



out put

[1, 2, 3, 4, 5, 6, 7]

[1, 2, 4, 5, 6, 7]

1 2 4 5 6 7

Comments

Popular posts from this blog

Operation on ArrayList in java

ArrayList program // collection framework in java

Vector in java collection, Vector object default creating and generic creation in class