vector

mail@pastecode.io avatar
unknown
plain_text
2 months ago
662 B
1
Indexable
Never
import java.util.Vector;

public class VectorExample {

public static void main(String[] args) {
      Vector<String> studVector = new Vector<String>();

    //1.add 2 students name
    studVector.addElement("Ali");
    studVector.addElement("Mimi");

    System.out.println(studVector.get(0));

    studVector.insertElementAt("Kin", 1);
    System.out.println(studVector.get(1));

    studVector.removeElementAt(1);
    studVector.add("Bill");
    studVector.addElement("Peter");

     System.out.println("Vector Size: " + studVector.size());

     for(String s : studVector){
        System.out.println("Name: " + s);
     }

}
  
}
Leave a Comment