Use of Vector in Java?

Vector is a dynamic array, which can grow automatically according to the required need. Vector class is in java.until package of java. Vector does not require any fix dimension like string like string array and int array. Vector contains many useful method.

//Code for Vector

import java.util.Vector;
public class VectorDemo
{
public static void main(Strind[], arg)
{
Vector<String> v = new Vector<String>();
v.add("1");
v.add("2");
v.add("3");
v.add("4");
v.add("5");
System.out.println(v.indexOf("2",4));
System.out.println(v.lastindexOf("1",5));
}
}

Happy codding..

Tags: , ,