Noor al.dulaimi
java question :)
1 Answer(s)      5 months and a day ago
Posted in : Java Interview Questions

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 Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.