Write a program to use different methods of Vector class.
for answer
Answers
Answered by
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
English,
9 days ago
World Languages,
19 days ago
English,
19 days ago
Math,
8 months ago
Chemistry,
8 months ago
Computer Science,
8 months ago