java question :)

java question :)

write java program to use vector in ArrayList with add, remove,sort

View Answers

December 19, 2012 at 10:59 PM

import java.util.Vector;

public class RemoveVectorElement {

public static void main(String[] args) {

    Vector<String> vc=new Vector<String>();

    //<E> it is return type of Vector

    //     add vector elements
    vc.add("Vector Element NOOR");
    vc.add("Vector Element MUAYAD");
    vc.add("Vector Element JAVA");
    vc.add("Vector Element ARRAYLIST");
    vc.add("Vector Element 201110166");

    // remove Vector element by index number
    vc.remove(3);

    // remove Vector element by Object value
    vc.remove("Vector Element 5");

    // get elements of Vector
    for(int i=0;i<vc.size();i++)
    {
        System.out.println("Vector Element "+i+" :"+vc.get(i));

} } }









Related Tutorials/Questions & Answers:

Ads