English, asked by nikitajadhav19012001, 19 days ago

Write a program to use different methods of Vector class.
for answer

Answers

Answered by joshuaabrahamshomu
1

Answer:

Explanation:

Java Vector Example

import java.util.*;  

public class VectorExample {  

      public static void main(String args[]) {  

         //Create a vector  

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

         //Adding elements using add() method of List  

         vec.add("Tiger");  

         vec.add("Lion");  

         vec.add("Dog");  

         vec.add("Elephant");  

         //Adding elements using addElement() method of Vector  

         vec.addElement("Rat");  

         vec.addElement("Cat");  

         vec.addElement("Deer");  

           

         System.out.println("Elements are: "+vec);  

      }  

}  

Similar questions